From 713697b34f1a1f716df97e331fd82782338c2083 Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Sun, 10 May 2009 18:13:45 +0200 Subject: [PATCH 01/11] ls-tree manpage: use "unless" instead of "when ... is not" Delayed negation in a statement is harder to spot and keep in mind. Signed-off-by: Alex Riesen Signed-off-by: Junio C Hamano --- Documentation/git-ls-tree.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/git-ls-tree.txt b/Documentation/git-ls-tree.txt index 4c7262f1cd..69c7dee1b9 100644 --- a/Documentation/git-ls-tree.txt +++ b/Documentation/git-ls-tree.txt @@ -76,7 +76,7 @@ Output Format ------------- SP SP TAB -When the `-z` option is not used, TAB, LF, and backslash characters +Unless the `-z` option is used, TAB, LF, and backslash characters in pathnames are represented as `\t`, `\n`, and `\\`, respectively. When the `-l` option is used, format changes to From c98a95eea825ffe66ed690064c80733656506c66 Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Sun, 10 May 2009 18:14:49 +0200 Subject: [PATCH 02/11] ls-tree manpage: output of ls-tree is compatible with update-index Such format relationships are very useful things to remember for script writers. Signed-off-by: Alex Riesen Signed-off-by: Junio C Hamano --- Documentation/git-ls-tree.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/git-ls-tree.txt b/Documentation/git-ls-tree.txt index 69c7dee1b9..3f87d7266b 100644 --- a/Documentation/git-ls-tree.txt +++ b/Documentation/git-ls-tree.txt @@ -78,6 +78,8 @@ Output Format Unless the `-z` option is used, TAB, LF, and backslash characters in pathnames are represented as `\t`, `\n`, and `\\`, respectively. +This output format is compatible with what '--index-info --stdin' of +'git update-index' expects. When the `-l` option is used, format changes to From 90f2e6526b3b800af4d10b900167a508b3774b98 Mon Sep 17 00:00:00 2001 From: Tony Kemp Date: Thu, 14 May 2009 16:47:41 +1000 Subject: [PATCH 03/11] Turn on USE_ST_TIMESPEC for OpenBSD Like Darwin, OpenBSD's stat struct uses st_ctimespec and st_mtimestruct rather than st_ctim and st_mtim. Signed-off-by: Tony Kemp Signed-off-by: Junio C Hamano --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 6e216436c3..26d180cc54 100644 --- a/Makefile +++ b/Makefile @@ -749,6 +749,7 @@ endif ifeq ($(uname_S),OpenBSD) NO_STRCASESTR = YesPlease NO_MEMMEM = YesPlease + USE_ST_TIMESPEC = YesPlease NEEDS_LIBICONV = YesPlease BASIC_CFLAGS += -I/usr/local/include BASIC_LDFLAGS += -L/usr/local/lib From ca156cfcc2dee5a1cee4f96023bb2f8c15a2c48c Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Sat, 16 May 2009 02:24:44 -0700 Subject: [PATCH 04/11] api-parse-options.txt: use 'func' instead of 'funct' Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- Documentation/technical/api-parse-options.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/technical/api-parse-options.txt b/Documentation/technical/api-parse-options.txt index e66ca9f70c..e30c602f47 100644 --- a/Documentation/technical/api-parse-options.txt +++ b/Documentation/technical/api-parse-options.txt @@ -198,7 +198,7 @@ The function must be defined in this form: The callback mechanism is as follows: -* Inside `funct`, the only interesting member of the structure +* Inside `func`, the only interesting member of the structure given by `opt` is the void pointer `opt->value`. `\*opt->value` will be the value that is saved into `var`, if you use `OPT_CALLBACK()`. From f044fe2de6f7bbace158853c075a4065f3722265 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Sat, 16 May 2009 02:24:45 -0700 Subject: [PATCH 05/11] tests: Add tests for missing format-patch long options Exercise format-patch's --signoff, --in-reply-to and --start-number long options. Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 11 +++++++++++ t/t4021-format-patch-numbered.sh | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 11061ddd5b..922a8941ed 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -505,4 +505,15 @@ test_expect_success 'format-patch from a subdirectory (3)' ' test -f "$basename" ' +test_expect_success 'format-patch --in-reply-to' ' + git format-patch -1 --stdout --in-reply-to "baz@foo.bar" > patch8 && + grep "^In-Reply-To: " patch8 && + grep "^References: " patch8 +' + +test_expect_success 'format-patch --signoff' ' + git format-patch -1 --signoff --stdout | + grep "^Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" +' + test_done diff --git a/t/t4021-format-patch-numbered.sh b/t/t4021-format-patch-numbered.sh index 390af2389f..3c27f0dc19 100755 --- a/t/t4021-format-patch-numbered.sh +++ b/t/t4021-format-patch-numbered.sh @@ -108,4 +108,10 @@ test_expect_success 'format.numbered = auto && --no-numbered' ' ' +test_expect_success '--start-number && --numbered' ' + + git format-patch --start-number 3 --numbered --stdout HEAD~1 > patch8 && + grep "^Subject: \[PATCH 3/3\]" patch8 +' + test_done From c646217e1366b0397552fad8c32acb47fbe8977d Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 16 May 2009 12:21:50 +0200 Subject: [PATCH 06/11] pre-commit.sample: don't print incidental SHA1 Make the sample pre-commit hook script discard all git-rev-parse output, not just stderr. Otherwise, it would print an SHA1. Signed-off-by: Jim Meyering Signed-off-by: Junio C Hamano --- templates/hooks--pre-commit.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample index 0e49279c7f..0ba62076fb 100755 --- a/templates/hooks--pre-commit.sample +++ b/templates/hooks--pre-commit.sample @@ -7,7 +7,7 @@ # # To enable this hook, rename this file to "pre-commit". -if git-rev-parse --verify HEAD 2>/dev/null +if git-rev-parse --verify HEAD >/dev/null 2>&1 then against=HEAD else From 77ebd56dc3d2efaeac87edc990cc1b99f331527c Mon Sep 17 00:00:00 2001 From: Daniel Cordero Date: Sat, 16 May 2009 10:54:45 -0700 Subject: [PATCH 07/11] builtin-checkout: Don't tell user that HEAD has moved before it has Previously, checkout would tell the user this message before moving HEAD, without regard to whether the upcoming move will result in success. If the move failed, this causes confusion. Show the message after the move, unless the move failed. Signed-off-by: Daniel Cordero Signed-off-by: Junio C Hamano --- builtin-checkout.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/builtin-checkout.c b/builtin-checkout.c index dc4bfb5fc0..f2d7ef01b0 100644 --- a/builtin-checkout.c +++ b/builtin-checkout.c @@ -541,14 +541,6 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new) parse_commit(new->commit); } - /* - * If we were on a detached HEAD, but we are now moving to - * a new commit, we want to mention the old commit once more - * to remind the user that it might be lost. - */ - if (!opts->quiet && !old.path && old.commit && new->commit != old.commit) - describe_detached_head("Previous HEAD position was", old.commit); - if (!old.commit && !opts->force) { if (!opts->quiet) { warning("You appear to be on a branch yet to be born."); @@ -561,6 +553,14 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new) if (ret) return ret; + /* + * If we were on a detached HEAD, but have now moved to + * a new commit, we want to mention the old commit once more + * to remind the user that it might be lost. + */ + if (!opts->quiet && !old.path && old.commit && new->commit != old.commit) + describe_detached_head("Previous HEAD position was", old.commit); + update_refs_for_switch(opts, &old, new); ret = post_checkout_hook(old.commit, new->commit, 1); From 8763dbb1b24c260243f69130c734c13563a16db6 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 16 May 2009 11:46:22 -0700 Subject: [PATCH 08/11] completion: fix PS1 display during a merge on detached HEAD If your merge stops in a conflict while on a detached HEAD, recent completion code fails to show anything. This was because various cases added to support the operation-in-progress markers (e.g. REBASE, MERGING) forgot that they need to set the variable "b" to something for the result they computed to be displayed at all. Probably not many people make trial merges on a detached HEAD (which is tremendously useful feature of git, by the way), and that may be why this was not noticed for a long time. Acked-By: Shawn O. Pearce Signed-off-by: Junio C Hamano --- contrib/completion/git-completion.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 1683e6d7b8..c2f8ea3444 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -99,10 +99,10 @@ __git_ps1 () elif [ -d "$g/rebase-merge" ]; then r="|REBASE-m" b="$(cat "$g/rebase-merge/head-name")" - elif [ -f "$g/MERGE_HEAD" ]; then - r="|MERGING" - b="$(git symbolic-ref HEAD 2>/dev/null)" else + if [ -f "$g/MERGE_HEAD" ]; then + r="|MERGING" + fi if [ -f "$g/BISECT_LOG" ]; then r="|BISECTING" fi From ff790b6a4bb7fa3bbccd5ea23cefd89da900aa2e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 10 May 2009 01:53:19 -0700 Subject: [PATCH 09/11] completion: simplify "current branch" in __git_ps1() As I very often work on a detached HEAD, I found it pretty confusing when __git_ps1() said 'some-name'. Did I create a branch with that name by mistake, or do I happen to be on a commit with that exact tag? This patch fixes the issue by enclosing non branch names in a pair of parentheses when used to substitute %s token in __git_ps1() argument. It also fixes a small bug where the branch part is left empty when .git/HEAD is unreadable for whatever reason. The output now says "(unknown)". Signed-off-by: Junio C Hamano --- contrib/completion/git-completion.bash | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index c2f8ea3444..be591468db 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -106,13 +106,14 @@ __git_ps1 () if [ -f "$g/BISECT_LOG" ]; then r="|BISECTING" fi - if ! b="$(git symbolic-ref HEAD 2>/dev/null)"; then - if ! b="$(git describe --exact-match HEAD 2>/dev/null)"; then - if [ -r "$g/HEAD" ]; then - b="$(cut -c1-7 "$g/HEAD")..." - fi - fi - fi + + b="$(git symbolic-ref HEAD 2>/dev/null)" || { + b="$(git describe --exact-match HEAD 2>/dev/null)" || + b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." || + b="unknown" + + b="($b)" + } fi local w From dd42c2f015102626562da05bb290f47862ea06fb Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 10 May 2009 01:56:21 -0700 Subject: [PATCH 10/11] completion: enhance "current branch" display Introduce GIT_PS1_DESCRIBE option you can set to "contains", "branch", or "describe" to tweak the way how a detached HEAD is described. The default behaviour is to describe only exact match with some tag (otherwise use the first 7 hexdigits) as before. Signed-off-by: Junio C Hamano --- contrib/completion/git-completion.bash | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index be591468db..dd6cd250e3 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -108,10 +108,21 @@ __git_ps1 () fi b="$(git symbolic-ref HEAD 2>/dev/null)" || { - b="$(git describe --exact-match HEAD 2>/dev/null)" || + + b="$( + case "${GIT_PS1_DESCRIBE_STYLE-}" in + (contains) + git describe --contains HEAD ;; + (branch) + git describe --contains --all HEAD ;; + (describe) + git describe HEAD ;; + (* | default) + git describe --exact-match HEAD ;; + esac 2>/dev/null)" || + b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." || b="unknown" - b="($b)" } fi From e4b09dad9f65395fd4bb8ab165012a3a6698a75b Mon Sep 17 00:00:00 2001 From: Nanako Shiraishi Date: Sun, 17 May 2009 11:43:08 +0900 Subject: [PATCH 11/11] test: checkout shouldn't say that HEAD has moved if it didn't MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: しらいしななこ Signed-off-by: Junio C Hamano --- t/t7201-co.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/t/t7201-co.sh b/t/t7201-co.sh index bdb808af1a..ebfd34df36 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -534,4 +534,12 @@ test_expect_success 'failing checkout -b should not break working tree' ' ' +test_expect_success 'switch out of non-branch' ' + git reset --hard master && + git checkout master^0 && + echo modified >one && + test_must_fail git checkout renamer 2>error.log && + ! grep "^Previous HEAD" error.log +' + test_done