From 4af3fab06e41d031ccb2b948ddd7c73159dd9d49 Mon Sep 17 00:00:00 2001 From: Pat Notz Date: Thu, 16 Sep 2010 14:53:23 -0600 Subject: [PATCH 01/13] strbuf.h: fix comment typo Signed-off-by: Pat Notz Signed-off-by: Junio C Hamano --- strbuf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strbuf.h b/strbuf.h index fac2dbc24f..675a91f938 100644 --- a/strbuf.h +++ b/strbuf.h @@ -16,7 +16,7 @@ * * 2. the ->buf member is a byte array that has at least ->len + 1 bytes * allocated. The extra byte is used to store a '\0', allowing the ->buf - * member to be a valid C-string. Every strbuf function ensure this + * member to be a valid C-string. Every strbuf function ensures this * invariant is preserved. * * Note that it is OK to "play" with the buffer directly if you work it From 4098f6717b8137493dddfc1a28a72b25769ed7bc Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Tue, 21 Sep 2010 18:45:09 +0100 Subject: [PATCH 02/13] t1503: Fix arithmetic expansion syntax error when using dash On systems which have dash as /bin/sh, such as Ubuntu, the final test (master@{n} for various n) fails with a syntax error while processing an arithmetic expansion. The syntax error is caused by using a bare name ('N') as a variable reference in the expression. In order to avoid the syntax error, we spell the variable reference as '$N' rather than simply 'N'. Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano --- t/t1503-rev-parse-verify.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh index 100f857b16..813cc1b3e2 100755 --- a/t/t1503-rev-parse-verify.sh +++ b/t/t1503-rev-parse-verify.sh @@ -106,8 +106,8 @@ test_expect_success 'use --default' ' test_expect_success 'master@{n} for various n' ' N=$(git reflog | wc -l) && - Nm1=$((N-1)) && - Np1=$((N+1)) && + Nm1=$(($N-1)) && + Np1=$(($N+1)) && git rev-parse --verify master@{0} && git rev-parse --verify master@{1} && git rev-parse --verify master@{$Nm1} && From 055467dd4ae7fac2cf3149352710a5ee64b2138c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 22 Sep 2010 12:15:37 -0700 Subject: [PATCH 03/13] CodingGuidelines: spell Arithmetic Expansion with $(($var)) POSIX wants shells to support both "N" and "$N" and requires them to yield the same answer to $((N)) and $(($N)), but we should aim for portability in a case like this, especially when the price we pay to do so is so small, i.e. a few extra dollars. Signed-off-by: Junio C Hamano --- Documentation/CodingGuidelines | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index b8bf618a30..8346c1972b 100644 --- a/Documentation/CodingGuidelines +++ b/Documentation/CodingGuidelines @@ -43,6 +43,10 @@ For shell scripts specifically (not exhaustive): - We use Arithmetic Expansion $(( ... )). + - Inside Arithmetic Expansion, spell shell variables with $ in front + of them, as some shells do not grok $((x)) while accepting $(($x)) + just fine (e.g. dash older than 0.5.4). + - No "Substring Expansion" ${parameter:offset:length}. - No shell arrays. From afa0876050496d4250e8b27680e5cbc60fbda760 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 21 Sep 2010 20:35:59 -0400 Subject: [PATCH 04/13] prefer test -h over test -L in shell scripts Even though "-L" is POSIX, the former is more portable, and we tend to prefer it already. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- contrib/workdir/git-new-workdir | 2 +- t/t9100-git-svn-basic.sh | 6 +++--- t/t9131-git-svn-empty-symlink.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir index 3ad2c0cea5..75e8b25817 100755 --- a/contrib/workdir/git-new-workdir +++ b/contrib/workdir/git-new-workdir @@ -42,7 +42,7 @@ then fi # don't link to a workdir -if test -L "$git_dir/config" +if test -h "$git_dir/config" then die "\"$orig_git\" is a working directory only, please specify" \ "a complete repository." diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh index 2f458f7a99..b041516a1d 100755 --- a/t/t9100-git-svn-basic.sh +++ b/t/t9100-git-svn-basic.sh @@ -143,7 +143,7 @@ test_expect_success "$name" ' git svn set-tree --find-copies-harder --rmdir \ ${remotes_git_svn}..mybranch5 && svn_cmd up "$SVN_TREE" && - test -L "$SVN_TREE"/exec.sh' + test -h "$SVN_TREE"/exec.sh' name='new symlink is added to a file that was also just made executable' @@ -156,7 +156,7 @@ test_expect_success "$name" ' ${remotes_git_svn}..mybranch5 && svn_cmd up "$SVN_TREE" && test -x "$SVN_TREE"/bar/zzz && - test -L "$SVN_TREE"/exec-2.sh' + test -h "$SVN_TREE"/exec-2.sh' name='modify a symlink to become a file' test_expect_success "$name" ' @@ -169,7 +169,7 @@ test_expect_success "$name" ' ${remotes_git_svn}..mybranch5 && svn_cmd up "$SVN_TREE" && test -f "$SVN_TREE"/exec-2.sh && - test ! -L "$SVN_TREE"/exec-2.sh && + test ! -h "$SVN_TREE"/exec-2.sh && test_cmp help "$SVN_TREE"/exec-2.sh' name="commit with UTF-8 message: locale: $GIT_SVN_LC_ALL" diff --git a/t/t9131-git-svn-empty-symlink.sh b/t/t9131-git-svn-empty-symlink.sh index 9a24a65b64..f762038f0e 100755 --- a/t/t9131-git-svn-empty-symlink.sh +++ b/t/t9131-git-svn-empty-symlink.sh @@ -88,7 +88,7 @@ test_expect_success 'enable broken symlink workaround' \ test_expect_success '"bar" is an empty file' 'test -f x/bar && ! test -s x/bar' test_expect_success 'get "bar" => symlink fix from svn' \ '(cd x && git svn rebase)' -test_expect_success SYMLINKS '"bar" becomes a symlink' 'test -L x/bar' +test_expect_success SYMLINKS '"bar" becomes a symlink' 'test -h x/bar' test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" y' From 861514d340021daa85bfa333c335932e9214988e Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Thu, 23 Sep 2010 14:33:51 +0200 Subject: [PATCH 05/13] contrib/completion: --no-index option to git diff Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 67569901e7..f83f019ca9 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1125,7 +1125,7 @@ _git_diff () case "$cur" in --*) __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex - --base --ours --theirs + --base --ours --theirs --no-index $__git_diff_common_options " return From 3695dc0af1bb5871430c028222d1af0a86720e62 Mon Sep 17 00:00:00 2001 From: Daniel Knittl-Frank Date: Fri, 24 Sep 2010 18:21:59 +0200 Subject: [PATCH 06/13] Improvements to `git checkout -h` be a little more verbose about what each option does Signed-off-by: Daniel Knittl-Frank Reviewed-by: Matthieu Moy Signed-off-by: Junio C Hamano --- builtin/checkout.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index 560eae1715..a54583b3a4 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -691,16 +691,16 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) "create and checkout a new branch"), OPT_STRING('B', NULL, &opts.new_branch_force, "branch", "create/reset and checkout a branch"), - OPT_BOOLEAN('l', NULL, &opts.new_branch_log, "log for new branch"), - OPT_SET_INT('t', "track", &opts.track, "track", + OPT_BOOLEAN('l', NULL, &opts.new_branch_log, "create reflog for new branch"), + OPT_SET_INT('t', "track", &opts.track, "set upstream info for new branch", BRANCH_TRACK_EXPLICIT), OPT_STRING(0, "orphan", &opts.new_orphan_branch, "new branch", "new unparented branch"), - OPT_SET_INT('2', "ours", &opts.writeout_stage, "stage", + OPT_SET_INT('2', "ours", &opts.writeout_stage, "checkout our version for unmerged files", 2), - OPT_SET_INT('3', "theirs", &opts.writeout_stage, "stage", + OPT_SET_INT('3', "theirs", &opts.writeout_stage, "checkout their version for unmerged files", 3), - OPT_BOOLEAN('f', "force", &opts.force, "force"), - OPT_BOOLEAN('m', "merge", &opts.merge, "merge"), + OPT_BOOLEAN('f', "force", &opts.force, "force checkout (throw away local modifications)"), + OPT_BOOLEAN('m', "merge", &opts.merge, "perform a 3-way merge with the new branch"), OPT_STRING(0, "conflict", &conflict_style, "style", "conflict style (merge or diff3)"), OPT_BOOLEAN('p', "patch", &patch_mode, "select hunks interactively"), From 95ad6d2de1f762f20edb52d139d3cc19529a581a Mon Sep 17 00:00:00 2001 From: Matthieu Moy Date: Fri, 24 Sep 2010 18:43:59 +0200 Subject: [PATCH 07/13] update comment and documentation for :/foo syntax The documentation in revisions.txt did not match the implementation, and the comment in sha1_name.c was incomplete. Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- Documentation/revisions.txt | 4 +++- sha1_name.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt index fe846f043c..3d4b79c480 100644 --- a/Documentation/revisions.txt +++ b/Documentation/revisions.txt @@ -107,11 +107,13 @@ the `$GIT_DIR/refs` directory or from the `$GIT_DIR/packed-refs` file. found. * A colon, followed by a slash, followed by a text (e.g. `:/fix nasty bug`): this names - a commit whose commit message starts with the specified text. + a commit whose commit message matches the specified regular expression. This name returns the youngest matching commit which is reachable from any ref. If the commit message starts with a '!', you have to repeat that; the special sequence ':/!', followed by something else than '!' is reserved for now. + The regular expression can match any part of the commit message. To + match messages starting with a string, one can use e.g. `:/^foo`. * A suffix ':' followed by a path (e.g. `HEAD:README`); this names the blob or tree at the given path in the tree-ish object named by the part diff --git a/sha1_name.c b/sha1_name.c index 7b7e61719f..484081de82 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -1062,6 +1062,7 @@ int get_sha1_with_context_1(const char *name, unsigned char *sha1, /* sha1:path --> object name of path in ent sha1 * :path -> object name of path in index * :[0-3]:path -> object name of path in index at stage + * :/foo -> recent commit matching foo */ if (name[0] == ':') { int stage = 0; From 831a8b843bc04bdac989514652149787b7f43da0 Mon Sep 17 00:00:00 2001 From: "Wesley J. Landaker" Date: Mon, 13 Sep 2010 08:59:54 -0600 Subject: [PATCH 08/13] Documentation: Refer to git-commit-tree in git-filter-branch help Currently, the help for git filter-branch refers users of --env-filter to git-commit for information about environment variables affecting commits. However, this information is not contained in the git-commit help, but is very explicitly detailed in git-commit-tree. Signed-off-by: Wesley J. Landaker Signed-off-by: Junio C Hamano --- Documentation/git-filter-branch.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt index 7357c8879a..f51860de26 100644 --- a/Documentation/git-filter-branch.txt +++ b/Documentation/git-filter-branch.txt @@ -81,7 +81,7 @@ OPTIONS This filter may be used if you only need to modify the environment in which the commit will be performed. Specifically, you might want to rewrite the author/committer name/email/time environment - variables (see linkgit:git-commit[1] for details). Do not forget + variables (see linkgit:git-commit-tree[1] for details). Do not forget to re-export the variables. --tree-filter :: From d212cef936d689d2a3b0932e678fce255362c72a Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sun, 26 Sep 2010 07:20:18 +0200 Subject: [PATCH 09/13] t6050 (replace): fix bogus "fetch branch with replacement" test The test was missing some "&&" at the end of some lines and it was wrong because, as the replacement refs were not fetched, the commits from the parallel branch should not show up. This was found by Elijah Newren. This is fixed by checking that after the branch from HASH6 is fetched, the commits from the parallel branch don't show up, and then by fetching the replacement refs and checking that they do show up afterwards. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- t/t6050-replace.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh index c907523e7e..95b180f469 100755 --- a/t/t6050-replace.sh +++ b/t/t6050-replace.sh @@ -205,9 +205,16 @@ test_expect_success 'fetch branch with replacement' ' git branch tofetch $HASH6 && ( cd clone_dir && - git fetch origin refs/heads/tofetch:refs/heads/parallel3 - git log --pretty=oneline parallel3 | grep $PARA3 - git show $PARA3 | grep "A U Thor" + git fetch origin refs/heads/tofetch:refs/heads/parallel3 && + git log --pretty=oneline parallel3 > output.txt && + ! grep $PARA3 output.txt && + git show $PARA3 > para3.txt && + grep "A U Thor" para3.txt && + git fetch origin "refs/replace/*:refs/replace/*" && + git log --pretty=oneline parallel3 > output.txt && + grep $PARA3 output.txt && + git show $PARA3 > para3.txt && + grep "O Thor" para3.txt ) ' From b822423ed20df158a478c9522373bffb04fa5ecc Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Sun, 26 Sep 2010 21:49:13 -0500 Subject: [PATCH 10/13] wt-status.c: don't leak directory entries when processing untracked,ignored When iterating through the list of directory entries, searching for untracked entries, only the entries added to the string_list were free'd. The rest (tracked or not matching the pathspec) were leaked. Ditto for the "ignored" loop. Rearrange the loops so that all entries are free'd. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- wt-status.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/wt-status.c b/wt-status.c index 54b6b03b9c..fc2438f60b 100644 --- a/wt-status.c +++ b/wt-status.c @@ -390,11 +390,9 @@ static void wt_status_collect_untracked(struct wt_status *s) fill_directory(&dir, s->pathspec); for (i = 0; i < dir.nr; i++) { struct dir_entry *ent = dir.entries[i]; - if (!cache_name_is_other(ent->name, ent->len)) - continue; - if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL)) - continue; - string_list_insert(&s->untracked, ent->name); + if (cache_name_is_other(ent->name, ent->len) && + match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL)) + string_list_insert(&s->untracked, ent->name); free(ent); } @@ -404,11 +402,9 @@ static void wt_status_collect_untracked(struct wt_status *s) fill_directory(&dir, s->pathspec); for (i = 0; i < dir.nr; i++) { struct dir_entry *ent = dir.entries[i]; - if (!cache_name_is_other(ent->name, ent->len)) - continue; - if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL)) - continue; - string_list_insert(&s->ignored, ent->name); + if (cache_name_is_other(ent->name, ent->len) && + match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL)) + string_list_insert(&s->ignored, ent->name); free(ent); } } From 61ef5e9b56e1c16f6d3c142e2c63f6e2c720c64e Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Sun, 26 Sep 2010 22:18:01 -0500 Subject: [PATCH 11/13] git-send-email.perl: ensure $domain is defined before using it valid_fqdn() may attempt to operate on an undefined value if Net::Domain::domainname fails to determine the domain name. This causes perl to emit unpleasant warnings. So, add a check for whether $domain has been defined before using it. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- git-send-email.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-send-email.perl b/git-send-email.perl index 6dab3bf6a7..e1f29a72a1 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -895,7 +895,7 @@ sub sanitize_address { sub valid_fqdn { my $domain = shift; - return !($^O eq 'darwin' && $domain =~ /\.local$/) && $domain =~ /\./; + return defined $domain && !($^O eq 'darwin' && $domain =~ /\.local$/) && $domain =~ /\./; } sub maildomain_net { From 9d14017adafc4829efc9e1393653579ad1d8ed71 Mon Sep 17 00:00:00 2001 From: Pat Notz Date: Thu, 16 Sep 2010 14:53:22 -0600 Subject: [PATCH 12/13] dir.c: squelch false uninitialized memory warning GCC 4.4.4 on MacOS incorrectly warns about potential use of uninitialized memory. Signed-off-by: Pat Notz Signed-off-by: Junio C Hamano --- dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dir.c b/dir.c index 133f472a1e..d1e5e5e5bf 100644 --- a/dir.c +++ b/dir.c @@ -232,7 +232,7 @@ int add_excludes_from_file_to_list(const char *fname, { struct stat st; int fd, i; - size_t size; + size_t size = 0; char *buf, *entry; fd = open(fname, O_RDONLY); From 442cb08fa0dca38c99cf1ff8a5654a95a5cad7a4 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 27 Sep 2010 12:14:57 -0700 Subject: [PATCH 13/13] Fix missing 'does' in man-page for 'git checkout' Reported-by: Rainer Standke Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- Documentation/git-checkout.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index f88e9977d1..22d36114df 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -45,14 +45,14 @@ successful. 'git checkout' [--patch] [] [--] ...:: - When or `--patch` are given, 'git checkout' *not* switch - branches. It updates the named paths in the working tree from - the index file or from a named (most often a commit). In - this case, the `-b` and `--track` options are meaningless and giving - either of them results in an error. The argument can be - used to specify a specific tree-ish (i.e. commit, tag or tree) - to update the index for the given paths before updating the - working tree. + When or `--patch` are given, 'git checkout' does *not* + switch branches. It updates the named paths in the working tree + from the index file or from a named (most often a + commit). In this case, the `-b` and `--track` options are + meaningless and giving either of them results in an error. The + argument can be used to specify a specific tree-ish + (i.e. commit, tag or tree) to update the index for the given + paths before updating the working tree. + The index may contain unmerged entries because of a previous failed merge. By default, if you try to check out such an entry from the index, the