Skip to content

Commit

Permalink
Merge branch 'maint-1.7.6' into maint
Browse files Browse the repository at this point in the history
* maint-1.7.6:
  notes_merge_commit(): do not pass temporary buffer to other function
  gitweb: Fix links to lines in blobs when javascript-actions are enabled
  mergetool: no longer need to save standard input
  mergetool: Use args as pathspec to unmerged files
  t9159-*.sh: skip for mergeinfo test for svn <= 1.4
  date.c: Support iso8601 timezone formats
  remote: only update remote-tracking branch if updating refspec
  remote rename: warn when refspec was not updated
  remote: "rename o foo" should not rename ref "origin/bar"
  remote: write correct fetch spec when renaming remote 'remote'
  • Loading branch information
Junio C Hamano committed Oct 26, 2011
2 parents 411e6cf + 8280baf commit f0911b9
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 93 deletions.
7 changes: 4 additions & 3 deletions Documentation/git-mergetool.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ Use `git mergetool` to run one of several merge utilities to resolve
merge conflicts. It is typically run after 'git merge'.

If one or more <file> parameters are given, the merge tool program will
be run to resolve differences on each file. If no <file> names are
specified, 'git mergetool' will run the merge tool program on every file
with merge conflicts.
be run to resolve differences on each file (skipping those without
conflicts). Specifying a directory will include all unresolved files in
that path. If no <file> names are specified, 'git mergetool' will run
the merge tool program on every file with merge conflicts.

OPTIONS
-------
Expand Down
28 changes: 21 additions & 7 deletions builtin/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ static int read_remote_branches(const char *refname,
unsigned char orig_sha1[20];
const char *symref;

strbuf_addf(&buf, "refs/remotes/%s", rename->old);
strbuf_addf(&buf, "refs/remotes/%s/", rename->old);
if (!prefixcmp(refname, buf.buf)) {
item = string_list_append(rename->remote_branches, xstrdup(refname));
symref = resolve_ref(refname, orig_sha1, 1, &flag);
Expand Down Expand Up @@ -621,10 +621,11 @@ static int mv(int argc, const char **argv)
OPT_END()
};
struct remote *oldremote, *newremote;
struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT, buf3 = STRBUF_INIT;
struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT, buf3 = STRBUF_INIT,
old_remote_context = STRBUF_INIT;
struct string_list remote_branches = STRING_LIST_INIT_NODUP;
struct rename_info rename;
int i;
int i, refspec_updated = 0;

if (argc != 3)
usage_with_options(builtin_remote_rename_usage, options);
Expand Down Expand Up @@ -659,15 +660,25 @@ static int mv(int argc, const char **argv)
strbuf_addf(&buf, "remote.%s.fetch", rename.new);
if (git_config_set_multivar(buf.buf, NULL, NULL, 1))
return error("Could not remove config section '%s'", buf.buf);
strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old);
for (i = 0; i < oldremote->fetch_refspec_nr; i++) {
char *ptr;

strbuf_reset(&buf2);
strbuf_addstr(&buf2, oldremote->fetch_refspec[i]);
ptr = strstr(buf2.buf, rename.old);
if (ptr)
strbuf_splice(&buf2, ptr-buf2.buf, strlen(rename.old),
rename.new, strlen(rename.new));
ptr = strstr(buf2.buf, old_remote_context.buf);
if (ptr) {
refspec_updated = 1;
strbuf_splice(&buf2,
ptr-buf2.buf + strlen(":refs/remotes/"),
strlen(rename.old), rename.new,
strlen(rename.new));
} else
warning("Not updating non-default fetch respec\n"
"\t%s\n"
"\tPlease update the configuration manually if necessary.",
buf2.buf);

if (git_config_set_multivar(buf.buf, buf2.buf, "^$", 0))
return error("Could not append '%s'", buf.buf);
}
Expand All @@ -685,6 +696,9 @@ static int mv(int argc, const char **argv)
}
}

if (!refspec_updated)
return 0;

/*
* First remove symrefs, then rename the rest, finally create
* the new symrefs.
Expand Down
34 changes: 23 additions & 11 deletions date.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,23 +552,35 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt
static int match_tz(const char *date, int *offp)
{
char *end;
int offset = strtoul(date+1, &end, 10);
int min, hour;
int n = end - date - 1;
int hour = strtoul(date + 1, &end, 10);
int n = end - (date + 1);
int min = 0;

min = offset % 100;
hour = offset / 100;
if (n == 4) {
/* hhmm */
min = hour % 100;
hour = hour / 100;
} else if (n != 2) {
min = 99; /* random crap */
} else if (*end == ':') {
/* hh:mm? */
min = strtoul(end + 1, &end, 10);
if (end - (date + 1) != 5)
min = 99; /* random crap */
} /* otherwise we parsed "hh" */

/*
* Don't accept any random crap.. At least 3 digits, and
* a valid minute. We might want to check that the minutes
* are divisible by 30 or something too.
* Don't accept any random crap. Even though some places have
* offset larger than 12 hours (e.g. Pacific/Kiritimati is at
* UTC+14), there is something wrong if hour part is much
* larger than that. We might also want to check that the
* minutes are divisible by 15 or something too. (Offset of
* Kathmandu, Nepal is UTC+5:45)
*/
if (min < 60 && n > 2) {
offset = hour*60+min;
if (min < 60 && hour < 24) {
int offset = hour * 60 + min;
if (*date == '-')
offset = -offset;

*offp = offset;
}
return end - date;
Expand Down
76 changes: 27 additions & 49 deletions git-mergetool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -342,64 +342,42 @@ merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo fa

last_status=0
rollup_status=0
rerere=false

files_to_merge() {
if test "$rerere" = true
then
git rerere remaining
else
git ls-files -u | sed -e 's/^[^ ]* //' | sort -u
fi
}

files=

if test $# -eq 0 ; then
cd_to_toplevel

if test -e "$GIT_DIR/MERGE_RR"
then
rerere=true
fi

files=$(files_to_merge)
if test -z "$files" ; then
echo "No files need merging"
exit 0
files=$(git rerere remaining)
else
files=$(git ls-files -u | sed -e 's/^[^ ]* //' | sort -u)
fi
else
files=$(git ls-files -u -- "$@" | sed -e 's/^[^ ]* //' | sort -u)
fi

# Save original stdin
exec 3<&0
if test -z "$files" ; then
echo "No files need merging"
exit 0
fi

printf "Merging:\n"
printf "$files\n"
printf "Merging:\n"
printf "$files\n"

files_to_merge |
while IFS= read i
do
if test $last_status -ne 0; then
prompt_after_failed_merge <&3 || exit 1
fi
printf "\n"
merge_file "$i" <&3
last_status=$?
if test $last_status -ne 0; then
rollup_status=1
fi
done
else
while test $# -gt 0; do
if test $last_status -ne 0; then
prompt_after_failed_merge || exit 1
fi
printf "\n"
merge_file "$1"
last_status=$?
if test $last_status -ne 0; then
rollup_status=1
fi
shift
done
fi
IFS='
'
for i in $files
do
if test $last_status -ne 0; then
prompt_after_failed_merge || exit 1
fi
printf "\n"
merge_file "$i"
last_status=$?
if test $last_status -ne 0; then
rollup_status=1
fi
done

exit $rollup_status
8 changes: 4 additions & 4 deletions gitweb/static/js/javascript-detection.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* and other reasons to not add 'js=1' param at the end of link
* @constant
*/
var jsExceptionsRe = /[;?]js=[01]$/;
var jsExceptionsRe = /[;?]js=[01](#.*)?$/;

/**
* Add '?js=1' or ';js=1' to the end of every link in the document
Expand All @@ -33,9 +33,9 @@ function fixLinks() {
var allLinks = document.getElementsByTagName("a") || document.links;
for (var i = 0, len = allLinks.length; i < len; i++) {
var link = allLinks[i];
if (!jsExceptionsRe.test(link)) { // =~ /[;?]js=[01]$/;
link.href +=
(link.href.indexOf('?') === -1 ? '?' : ';') + 'js=1';
if (!jsExceptionsRe.test(link)) {
link.href = link.href.replace(/(#|$)/,
(link.href.indexOf('?') === -1 ? '?' : ';') + 'js=1$1');
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion notes-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ int notes_merge_commit(struct notes_merge_options *o,
* Finally store the new commit object SHA1 into 'result_sha1'.
*/
struct dir_struct dir;
const char *path = git_path(NOTES_MERGE_WORKTREE "/");
char *path = xstrdup(git_path(NOTES_MERGE_WORKTREE "/"));
int path_len = strlen(path), i;
const char *msg = strstr(partial_commit->buffer, "\n\n");

Expand Down Expand Up @@ -720,6 +720,7 @@ int notes_merge_commit(struct notes_merge_options *o,
result_sha1);
OUTPUT(o, 4, "Finalized notes merge commit: %s",
sha1_to_hex(result_sha1));
free(path);
return 0;
}

Expand Down
6 changes: 6 additions & 0 deletions t/t0006-date.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ check_parse 2008-02 bad
check_parse 2008-02-14 bad
check_parse '2008-02-14 20:30:45' '2008-02-14 20:30:45 +0000'
check_parse '2008-02-14 20:30:45 -0500' '2008-02-14 20:30:45 -0500'
check_parse '2008-02-14 20:30:45 -0015' '2008-02-14 20:30:45 -0015'
check_parse '2008-02-14 20:30:45 -5' '2008-02-14 20:30:45 +0000'
check_parse '2008-02-14 20:30:45 -5:' '2008-02-14 20:30:45 +0000'
check_parse '2008-02-14 20:30:45 -05' '2008-02-14 20:30:45 -0500'
check_parse '2008-02-14 20:30:45 -:30' '2008-02-14 20:30:45 +0000'
check_parse '2008-02-14 20:30:45 -05:00' '2008-02-14 20:30:45 -0500'
check_parse '2008-02-14 20:30:45' '2008-02-14 20:30:45 -0500' EST5

check_approxidate() {
Expand Down
31 changes: 31 additions & 0 deletions t/t5505-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,37 @@ test_expect_success 'rename a remote' '
'

test_expect_success 'rename does not update a non-default fetch refspec' '
git clone one four.one &&
(cd four.one &&
git config remote.origin.fetch +refs/heads/*:refs/heads/origin/* &&
git remote rename origin upstream &&
test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/heads/origin/*" &&
git rev-parse -q origin/master)
'

test_expect_success 'rename a remote with name part of fetch spec' '
git clone one four.two &&
(cd four.two &&
git remote rename origin remote &&
git remote rename remote upstream &&
test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*")
'

test_expect_success 'rename a remote with name prefix of other remote' '
git clone one four.three &&
(cd four.three &&
git remote add o git://example.com/repo.git &&
git remote rename o upstream &&
test "$(git rev-parse origin/master)" = "$(git rev-parse master)")
'

cat > remotes_origin << EOF
URL: $(pwd)/one
Push: refs/heads/master:refs/heads/upstream
Expand Down
Loading

0 comments on commit f0911b9

Please sign in to comment.