Re: [PATCH] Port git commit to C.
- From
Alex Riesen <raa.lkml@gmail.com>
- Date
- Nov 8, 2007, 23:27 UTC
- Message-ID
- <20071108232751.GC4899@steel.home>
- In-Reply-To
- <1194541140-3062-1-git-send-email-krh@redhat.com>
Kristian Høgsberg, Thu, Nov 08, 2007 17:59:00 +0100:
> This makes git commit a builtin and moves git-commit.sh to > contrib/examples. This also removes the git-runstatus > helper, which was mostly just a git-status.sh implementation detail.
Applied instead of 00c8febf563da on Junio's pu it breaks t1400:
* expecting success: echo TEST >F &&
git add F &&
GIT_AUTHOR_DATE="2005-05-26 23:30" \
GIT_COMMITTER_DATE="2005-05-26 23:30" git-commit -m add -a &&
h_TEST=$(git rev-parse --verify HEAD)
echo The other day this did not work. >M &&
echo And then Bob told me how to fix it. >>M &&
echo OTHER >F &&
GIT_AUTHOR_DATE="2005-05-26 23:41" \
GIT_COMMITTER_DATE="2005-05-26 23:41" git-commit -F M -a &&
h_OTHER=$(git rev-parse --verify HEAD) &&
GIT_AUTHOR_DATE="2005-05-26 23:44" \
GIT_COMMITTER_DATE="2005-05-26 23:44" git-commit --amend &&
h_FIXED=$(git rev-parse --verify HEAD) &&
echo Merged initial commit and a later commit. >M &&
echo $h_TEST >.git/MERGE_HEAD &&
GIT_AUTHOR_DATE="2005-05-26 23:45" \
GIT_COMMITTER_DATE="2005-05-26 23:45" git-commit -F M &&
h_MERGED=$(git rev-parse --verify HEAD)
rm -f M
Created initial commit 2bc82dd: add
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 F
Created commit d244b72: The other day this did not work.
1 files changed, 1 insertions(+), 1 deletions(-)
launching editor, log (null)
fatal: * no commit message? aborting commit.
* ok 28: creating initial files* expecting success: diff expect .git/logs/refs/heads/master
3,4d2
< d244b725ca2c5f8aaacd9df2468b890499380862 C O Mitter <committer@example.com> 1117151040 +0000 commit (amend): The other day this did not work.
< C O Mitter <committer@example.com> 1117151100 +0000 commit (merge): Merged initial commit and a later commit.
* FAIL 29: git-commit logged updates
diff expect .git/logs/refs/heads/masterWhich is not the test actually failed. The failed one is 28, but the last "rm -f M" killed the error because of missed "&&" before it.
I believe you need something like this to fix the test:
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index ce045b2..a90824b 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -205,7 +205,7 @@ test_expect_success \ echo $h_TEST >.git/MERGE_HEAD && GIT_AUTHOR_DATE="2005-05-26 23:45" \ GIT_COMMITTER_DATE="2005-05-26 23:45" git-commit -F M && - h_MERGED=$(git rev-parse --verify HEAD) + h_MERGED=$(git rev-parse --verify HEAD) && rm -f M' cat >expect <<EOF and something like this to refill the strbuf of commit message with the text read from the amended commit (the failed test was a "git commit --amend"). The patch is on top of yours "Export launch_editor() and make it accept ':' as a no-op editor": diff --git a/builtin-tag.c b/builtin-tag.c index c3b76da..8ca9ffb 100644 --- a/builtin-tag.c +++ b/builtin-tag.c @@ -42,17 +42,17 @@ void launch_editor(const char *path, struct strbuf *buffer) if (!editor) editor = "vi"; - if (!strcmp(editor, ":")) - return; - - memset(&child, 0, sizeof(child)); - child.argv = args; - args[0] = editor; - args[1] = path; - args[2] = NULL; - - if (run_command(&child)) - die("There was a problem with the editor %s.", editor); + if (strcmp(editor, ":")) + { + memset(&child, 0, sizeof(child)); + child.argv = args; + args[0] = editor; + args[1] = path; + args[2] = NULL; + + if (run_command(&child)) + die("There was a problem with the editor %s.", editor); + } if (strbuf_read_file(buffer, path, 0) < 0) die("could not read message file '%s': %s",