From 588071112c7ca14a04d674e4f019572f0bb77326 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 15 Feb 2008 09:37:54 -0800 Subject: diff.c: fixup garding of config parser from value=NULL Christian Couder noticed that there still were a handcrafted error() call that we should have converted to config_error_nonbool() where parse_lldiff_command() parses the configuration file. Signed-off-by: Junio C Hamano --- diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff.c b/diff.c index 4d2e23ae1b..2aaace890c 100644 --- a/diff.c +++ b/diff.c @@ -87,7 +87,7 @@ static int parse_lldiff_command(const char *var, const char *ep, const char *val } if (!value) - return error("%s: lacks value", var); + return config_error_nonbool(var); drv->cmd = strdup(value); return 0; } -- cgit v1.2.3 From 8ca496e97d100195c9015f4da8ddaad693e91961 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Thu, 14 Feb 2008 06:50:00 +0100 Subject: diff.c: replace a 'strdup' with 'xstrdup'. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff.c b/diff.c index 2aaace890c..047310fc94 100644 --- a/diff.c +++ b/diff.c @@ -88,7 +88,7 @@ static int parse_lldiff_command(const char *var, const char *ep, const char *val if (!value) return config_error_nonbool(var); - drv->cmd = strdup(value); + drv->cmd = xstrdup(value); return 0; } -- cgit v1.2.3 From df93e33c8bc8c79751a45d8005c6a92b18d4ba6d Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Fri, 15 Feb 2008 14:14:18 -0500 Subject: Validate nicknames of remote branches to prohibit confusing ones The original problem was that the parsers for configuration files were getting confused by seeing as nicknames remotes that involved directory-changing characters. In particular, the branches config file for ".." was particularly mystifying on platforms that can open directories and read odd data from them. The validation function was written by Junio Hamano (with a typo corrected). Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- remote.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/remote.c b/remote.c index 20abbc07ac..6b56473f5b 100644 --- a/remote.c +++ b/remote.c @@ -343,6 +343,16 @@ struct refspec *parse_ref_spec(int nr_refspec, const char **refspec) return rs; } +static int valid_remote_nick(const char *name) +{ + if (!name[0] || /* not empty */ + (name[0] == '.' && /* not "." */ + (!name[1] || /* not ".." */ + (name[1] == '.' && !name[2])))) + return 0; + return !strchr(name, '/'); /* no slash */ +} + struct remote *remote_get(const char *name) { struct remote *ret; @@ -351,7 +361,7 @@ struct remote *remote_get(const char *name) if (!name) name = default_remote_name; ret = make_remote(name, 0); - if (name[0] != '/') { + if (valid_remote_nick(name)) { if (!ret->url) read_remotes_file(ret); if (!ret->url) -- cgit v1.2.3 From e8b32e061006d1a62e464e7c2a5385ddd0cb4290 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 14 Feb 2008 01:34:34 -0500 Subject: fast-import: check return value from unpack_entry() If the tree object we have asked for is deltafied in the packfile and the delta did not apply correctly or was not able to be decompressed from the packfile then we can get back NULL instead of the tree data. This is (part of) the reason why read_sha1_file() can return NULL, so we need to also handle it the same way. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- fast-import.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fast-import.c b/fast-import.c index a523b171e2..9b71ccc479 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1204,6 +1204,8 @@ static void load_tree(struct tree_entry *root) die("Not a tree: %s", sha1_to_hex(sha1)); t->delta_depth = myoe->depth; buf = gfi_unpack_entry(myoe, &size); + if (!buf) + die("Can't load tree %s", sha1_to_hex(sha1)); } else { enum object_type type; buf = read_sha1_file(sha1, &type, &size); -- cgit v1.2.3 From 2c778210f8877e8f5c88715c2d25d1a43d976566 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 16 Feb 2008 05:59:53 +0100 Subject: diff.c: remove useless check for value != NULL It is not necessary to check if value != NULL before calling 'parse_lldiff_command' as there is already a check inside this function. By the way this patch also improves the existing check inside 'parse_lldiff_command' by using: return config_error_nonbool(var); instead of: return error("%s: lacks value", var); Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- diff.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/diff.c b/diff.c index 047310fc94..ed41ce418e 100644 --- a/diff.c +++ b/diff.c @@ -166,13 +166,8 @@ int git_diff_ui_config(const char *var, const char *value) if (!prefixcmp(var, "diff.")) { const char *ep = strrchr(var, '.'); - if (ep != var + 4) { - if (!strcmp(ep, ".command")) { - if (!value) - return config_error_nonbool(var); - return parse_lldiff_command(var, ep, value); - } - } + if (ep != var + 4 && !strcmp(ep, ".command")) + return parse_lldiff_command(var, ep, value); } return git_diff_basic_config(var, value); -- cgit v1.2.3 From ea5105a5e3c6629ee64b499ea918c2b80882fc22 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 16 Feb 2008 06:00:24 +0100 Subject: config: add 'git_config_string' to refactor string config variables. In many places we just check if a value from the config file is not NULL, then we duplicate it and return 0. This patch introduces the new 'git_config_string' function to do that. This function is also used to refactor some code in 'config.c'. Refactoring other files is left for other patches. Also not all the code in "config.c" is refactored, because the function takes a "const char **" as its first parameter, but in many places a "char *" is used instead of a "const char *". (And C does not allow using a "char **" instead of a "const char **" without a warning.) Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- cache.h | 1 + config.c | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cache.h b/cache.h index 6abcee4372..c83b123fa5 100644 --- a/cache.h +++ b/cache.h @@ -584,6 +584,7 @@ extern int git_parse_ulong(const char *, unsigned long *); extern int git_config_int(const char *, const char *); extern unsigned long git_config_ulong(const char *, const char *); extern int git_config_bool(const char *, const char *); +extern int git_config_string(const char **, const char *, const char *); extern int git_config_set(const char *, const char *); extern int git_config_set_multivar(const char *, const char *, const char *, int); extern int git_config_rename_section(const char *, const char *); diff --git a/config.c b/config.c index 3f4d3b1602..7b8615d87d 100644 --- a/config.c +++ b/config.c @@ -309,6 +309,14 @@ int git_config_bool(const char *name, const char *value) return git_config_int(name, value) != 0; } +int git_config_string(const char **dest, const char *var, const char *value) +{ + if (!value) + return config_error_nonbool(var); + *dest = xstrdup(value); + return 0; +} + int git_default_config(const char *var, const char *value) { /* This needs a better name */ @@ -421,20 +429,11 @@ int git_default_config(const char *var, const char *value) return 0; } - if (!strcmp(var, "i18n.commitencoding")) { - if (!value) - return config_error_nonbool(var); - git_commit_encoding = xstrdup(value); - return 0; - } - - if (!strcmp(var, "i18n.logoutputencoding")) { - if (!value) - return config_error_nonbool(var); - git_log_output_encoding = xstrdup(value); - return 0; - } + if (!strcmp(var, "i18n.commitencoding")) + return git_config_string(&git_commit_encoding, var, value); + if (!strcmp(var, "i18n.logoutputencoding")) + return git_config_string(&git_log_output_encoding, var, value); if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) { pager_use_color = git_config_bool(var,value); -- cgit v1.2.3 From 872da32d80c004c26a19a5d6cb31eb3e7f034094 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 16 Feb 2008 06:01:11 +0100 Subject: Add "const" qualifier to "char *pager_program". Also use "git_config_string" to simplify "config.c" code where "pager_program" is set. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- cache.h | 2 +- config.c | 8 ++------ environment.c | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/cache.h b/cache.h index c83b123fa5..1ecaef14c3 100644 --- a/cache.h +++ b/cache.h @@ -610,7 +610,7 @@ extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char /* pager.c */ extern void setup_pager(void); -extern char *pager_program; +extern const char *pager_program; extern int pager_in_use(void); extern int pager_use_color; diff --git a/config.c b/config.c index 7b8615d87d..eb6d2ad78b 100644 --- a/config.c +++ b/config.c @@ -440,12 +440,8 @@ int git_default_config(const char *var, const char *value) return 0; } - if (!strcmp(var, "core.pager")) { - if (!value) - return config_error_nonbool(var); - pager_program = xstrdup(value); - return 0; - } + if (!strcmp(var, "core.pager")) + return git_config_string(&pager_program, var, value); if (!strcmp(var, "core.editor")) { if (!value) diff --git a/environment.c b/environment.c index 18a1c4eec4..b8869e972e 100644 --- a/environment.c +++ b/environment.c @@ -30,7 +30,7 @@ int core_compression_seen; size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE; size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT; size_t delta_base_cache_limit = 16 * 1024 * 1024; -char *pager_program; +const char *pager_program; int pager_use_color = 1; char *editor_program; char *excludes_file; -- cgit v1.2.3 From ee9601e6bef2281e3183e127e1e4e36ed257af7a Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 16 Feb 2008 06:01:41 +0100 Subject: Add "const" qualifier to "char *editor_program". Also use "git_config_string" to simplify "config.c" code where "editor_program" is set. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- cache.h | 2 +- config.c | 8 ++------ environment.c | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/cache.h b/cache.h index 1ecaef14c3..ce7b386a4d 100644 --- a/cache.h +++ b/cache.h @@ -614,7 +614,7 @@ extern const char *pager_program; extern int pager_in_use(void); extern int pager_use_color; -extern char *editor_program; +extern const char *editor_program; extern char *excludes_file; /* base85 */ diff --git a/config.c b/config.c index eb6d2ad78b..703c2085a5 100644 --- a/config.c +++ b/config.c @@ -443,12 +443,8 @@ int git_default_config(const char *var, const char *value) if (!strcmp(var, "core.pager")) return git_config_string(&pager_program, var, value); - if (!strcmp(var, "core.editor")) { - if (!value) - return config_error_nonbool(var); - editor_program = xstrdup(value); - return 0; - } + if (!strcmp(var, "core.editor")) + return git_config_string(&editor_program, var, value); if (!strcmp(var, "core.excludesfile")) { if (!value) diff --git a/environment.c b/environment.c index b8869e972e..9556009324 100644 --- a/environment.c +++ b/environment.c @@ -32,7 +32,7 @@ size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT; size_t delta_base_cache_limit = 16 * 1024 * 1024; const char *pager_program; int pager_use_color = 1; -char *editor_program; +const char *editor_program; char *excludes_file; int auto_crlf = 0; /* 1: both ways, -1: only when adding git objects */ unsigned whitespace_rule_cfg = WS_DEFAULT_RULE; -- cgit v1.2.3 From dfb068be8deef2065970b2a7889acc51abf4dd78 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 16 Feb 2008 06:01:59 +0100 Subject: Add "const" qualifier to "char *excludes_file". Also use "git_config_string" to simplify "config.c" code where "excludes_file" is set. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- cache.h | 2 +- config.c | 8 ++------ environment.c | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/cache.h b/cache.h index ce7b386a4d..43ba6a3ba5 100644 --- a/cache.h +++ b/cache.h @@ -615,7 +615,7 @@ extern int pager_in_use(void); extern int pager_use_color; extern const char *editor_program; -extern char *excludes_file; +extern const char *excludes_file; /* base85 */ int decode_85(char *dst, const char *line, int linelen); diff --git a/config.c b/config.c index 703c2085a5..b82907cb85 100644 --- a/config.c +++ b/config.c @@ -446,12 +446,8 @@ int git_default_config(const char *var, const char *value) if (!strcmp(var, "core.editor")) return git_config_string(&editor_program, var, value); - if (!strcmp(var, "core.excludesfile")) { - if (!value) - return config_error_nonbool(var); - excludes_file = xstrdup(value); - return 0; - } + if (!strcmp(var, "core.excludesfile")) + return git_config_string(&excludes_file, var, value); if (!strcmp(var, "core.whitespace")) { if (!value) diff --git a/environment.c b/environment.c index 9556009324..fa3633372b 100644 --- a/environment.c +++ b/environment.c @@ -33,7 +33,7 @@ size_t delta_base_cache_limit = 16 * 1024 * 1024; const char *pager_program; int pager_use_color = 1; const char *editor_program; -char *excludes_file; +const char *excludes_file; int auto_crlf = 0; /* 1: both ways, -1: only when adding git objects */ unsigned whitespace_rule_cfg = WS_DEFAULT_RULE; -- cgit v1.2.3 From b20a60d0c0f23384cb4141d75d9a7c90e99c1432 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 16 Feb 2008 06:02:17 +0100 Subject: diff.c: add "const" qualifier to "char *cmd" member of "struct ll_diff_driver" Also use "git_config_string" to simplify code where "cmd" is set. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- diff.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/diff.c b/diff.c index ed41ce418e..f082f55bc5 100644 --- a/diff.c +++ b/diff.c @@ -57,7 +57,7 @@ static int parse_diff_color_slot(const char *var, int ofs) static struct ll_diff_driver { const char *name; struct ll_diff_driver *next; - char *cmd; + const char *cmd; } *user_diff, **user_diff_tail; /* @@ -86,10 +86,7 @@ static int parse_lldiff_command(const char *var, const char *ep, const char *val user_diff_tail = &(drv->next); } - if (!value) - return config_error_nonbool(var); - drv->cmd = xstrdup(value); - return 0; + return git_config_string(&(drv->cmd), var, value); } /* -- cgit v1.2.3 From 87f1b8849bf0094e0b20cd294e1f2b04976ddf41 Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Fri, 15 Feb 2008 16:53:36 -0500 Subject: mailinfo: feed only one line to handle_filter() for QP input The function is intended to be fed one logical line at a time to inspect, but a QP encoded raw input line can have more than one lines, just like BASE64 encoded one. Quoting LF as =0A may be unusual but RFC2045 allows it. The issue was noticed and fixed by Jay Soffian. JC added a test to protect the fix from regressing later. Signed-off-by: Jay Soffian Signed-off-by: Junio C Hamano --- builtin-mailinfo.c | 1 + t/t5100-mailinfo.sh | 2 +- t/t5100/info0009 | 5 +++++ t/t5100/msg0009 | 2 ++ t/t5100/patch0009 | 13 +++++++++++++ t/t5100/sample.mbox | 23 +++++++++++++++++++++++ 6 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 t/t5100/info0009 create mode 100644 t/t5100/msg0009 create mode 100644 t/t5100/patch0009 diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c index 2600847974..11f154b31f 100644 --- a/builtin-mailinfo.c +++ b/builtin-mailinfo.c @@ -818,6 +818,7 @@ static void handle_body(void) switch (transfer_encoding) { case TE_BASE64: + case TE_QP: { char *op = line; diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh index 9b1a74542a..d6c55c1157 100755 --- a/t/t5100-mailinfo.sh +++ b/t/t5100-mailinfo.sh @@ -11,7 +11,7 @@ test_expect_success 'split sample box' \ 'git mailsplit -o. ../t5100/sample.mbox >last && last=`cat last` && echo total is $last && - test `cat last` = 8' + test `cat last` = 9' for mail in `echo 00*` do diff --git a/t/t5100/info0009 b/t/t5100/info0009 new file mode 100644 index 0000000000..2a66321c80 --- /dev/null +++ b/t/t5100/info0009 @@ -0,0 +1,5 @@ +Author: F U Bar +Email: f.u.bar@example.com +Subject: updates +Date: Mon, 17 Sep 2001 00:00:00 +0900 + diff --git a/t/t5100/msg0009 b/t/t5100/msg0009 new file mode 100644 index 0000000000..9ffe131489 --- /dev/null +++ b/t/t5100/msg0009 @@ -0,0 +1,2 @@ +This is to fix diff-format documentation. + diff --git a/t/t5100/patch0009 b/t/t5100/patch0009 new file mode 100644 index 0000000000..65615c34af --- /dev/null +++ b/t/t5100/patch0009 @@ -0,0 +1,13 @@ +diff --git a/Documentation/diff-format.txt b/Documentation/diff-format.txt +index b426a14..97756ec 100644 +--- a/Documentation/diff-format.txt ++++ b/Documentation/diff-format.txt +@@ -81,7 +81,7 @@ The "diff" formatting options can be customized via the + environment variable 'GIT_DIFF_OPTS'. For example, if you + prefer context diff: + +- GIT_DIFF_OPTS=-c git-diff-index -p $(cat .git/HEAD) ++ GIT_DIFF_OPTS=-c git-diff-index -p HEAD + + + 2. When the environment variable 'GIT_EXTERNAL_DIFF' is set, the diff --git a/t/t5100/sample.mbox b/t/t5100/sample.mbox index 070c1661b9..0476b96c33 100644 --- a/t/t5100/sample.mbox +++ b/t/t5100/sample.mbox @@ -407,3 +407,26 @@ Subject: [PATCH] another patch Hey you forgot the patch! +From nobody Mon Sep 17 00:00:00 2001 +From: A U Thor +Date: Mon, 17 Sep 2001 00:00:00 +0900 +Mime-Version: 1.0 +Content-Type: Text/Plain; charset=us-ascii +Content-Transfer-Encoding: Quoted-Printable + +=0A=0AFrom: F U Bar +Subject: [PATCH] updates=0A=0AThis is to fix diff-format documentation. + +diff --git a/Documentation/diff-format.txt b/Documentation/diff-format.txt +index b426a14..97756ec 100644 +--- a/Documentation/diff-format.txt ++++ b/Documentation/diff-format.txt +@@ -81,7 +81,7 @@ The "diff" formatting options can be customized via the + environment variable 'GIT_DIFF_OPTS'. For example, if you + prefer context diff: +=20 +- GIT_DIFF_OPTS=3D-c git-diff-index -p $(cat .git/HEAD) ++ GIT_DIFF_OPTS=3D-c git-diff-index -p HEAD +=20 +=20 + 2. When the environment variable 'GIT_EXTERNAL_DIFF' is set, the -- cgit v1.2.3 From 13bf1a99764ea751f6fa75502309d8b91529623a Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Fri, 15 Feb 2008 22:20:44 +0100 Subject: hg-to-git: fix parent analysis Fix a bug in the hg-to-git convertor introduced by commit 1bc7c13af9f936aa80893100120b542338a10bf4: when searching the changeset parents, 'hg log' returns an extra space at the end of the line, which confuses the .split(' ') based tokenizer: Traceback (most recent call last): File "hg-to-git.py", line 123, in hgchildren[mparent] += ( str(cset), ) KeyError: '' Signed-off-by: Stelian Pop Signed-off-by: Junio C Hamano --- contrib/hg-to-git/hg-to-git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/hg-to-git/hg-to-git.py b/contrib/hg-to-git/hg-to-git.py index c35b15860d..d72ffbb777 100755 --- a/contrib/hg-to-git/hg-to-git.py +++ b/contrib/hg-to-git/hg-to-git.py @@ -111,7 +111,7 @@ hgparents["0"] = (None, None) hgbranch["0"] = "master" for cset in range(1, int(tip) + 1): hgchildren[str(cset)] = () - prnts = os.popen('hg log -r %d --template "{parents}"' % cset).read().split(' ') + prnts = os.popen('hg log -r %d --template "{parents}"' % cset).read().strip().split(' ') prnts = map(lambda x: x[:x.find(':')], prnts) if prnts[0] != '': parent = prnts[0].strip() -- cgit v1.2.3 From 0ef617f4b6ea78ad63dd11e90f8c854238176981 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 15 Feb 2008 20:30:05 -0800 Subject: diff: Fix miscounting of --check output c1795bb (Unify whitespace checking) incorrectly made the checking function return without incrementing the line numbers when there is no whitespace problem is found on a '+' line. This resurrects the earlier behaviour. Noticed and reported by Jay Soffian. The test script was stolen from Jay's independent fix. Signed-off-by: Junio C Hamano --- diff.c | 4 ++-- t/t4015-diff-whitespace.sh | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/diff.c b/diff.c index f082f55bc5..39f6e21aa3 100644 --- a/diff.c +++ b/diff.c @@ -1013,6 +1013,7 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len) char *err; if (line[0] == '+') { + data->lineno++; data->status = check_and_emit_line(line + 1, len - 1, data->ws_rule, NULL, NULL, NULL, NULL); if (!data->status) @@ -1023,13 +1024,12 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len) emit_line(set, reset, line, 1); (void)check_and_emit_line(line + 1, len - 1, data->ws_rule, stdout, set, reset, ws); - data->lineno++; } else if (line[0] == ' ') data->lineno++; else if (line[0] == '@') { char *plus = strchr(line, '+'); if (plus) - data->lineno = strtol(plus, NULL, 10); + data->lineno = strtol(plus, NULL, 10) - 1; else die("invalid diff"); } diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index d30169fbdc..83c54b747f 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -326,4 +326,13 @@ test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab: ! git diff --check ' + +test_expect_success 'line numbers in --check output are correct' ' + + echo "" > x && + echo "foo(); " >> x && + git diff --check | grep "x:2:" + +' + test_done -- cgit v1.2.3 From 1fe32cb9d0807e6da468dc7bf96d427b2f38c1c4 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 15 Feb 2008 23:57:26 -0800 Subject: filter-branch: handle filenames that need quoting The command used a very old fashioned construct to extract filenames out of diff-index and ended up corrupting the output. We can simply use --name-only and pipe into --stdin mode of update-index. It's been like that for the past 2 years or so since a94d994 (update-index: work with c-quoted name). Signed-off-by: Junio C Hamano --- git-filter-branch.sh | 9 +++++---- t/t7003-filter-branch.sh | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/git-filter-branch.sh b/git-filter-branch.sh index ff716cabb0..49e13f0bb1 100755 --- a/git-filter-branch.sh +++ b/git-filter-branch.sh @@ -276,10 +276,11 @@ while read commit parents; do eval "$filter_tree" < /dev/null || die "tree filter failed: $filter_tree" - git diff-index -r $commit | cut -f 2- | tr '\012' '\000' | \ - xargs -0 git update-index --add --replace --remove - git ls-files -z --others | \ - xargs -0 git update-index --add --replace --remove + ( + git diff-index -r --name-only $commit + git ls-files --others + ) | + git update-index --add --replace --remove --stdin fi eval "$filter_index" < /dev/null || diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh index 5f60b22d87..868babc4b2 100755 --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@ -165,4 +165,18 @@ test_expect_success '"map" works in commit filter' ' git rev-parse --verify master ' +test_expect_success 'Name needing quotes' ' + + git checkout -b rerere A && + mkdir foo && + name="れれれ" && + >foo/$name && + git add foo && + git commit -m "Adding a file" && + git filter-branch --tree-filter "rm -fr foo" && + ! git ls-files --error-unmatch "foo/$name" && + test $(git rev-parse --verify rerere) != $(git rev-parse --verify A) + +' + test_done -- cgit v1.2.3 From 959ba670ad7173bcb73afaca69625a5635f63b8b Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 14 Feb 2008 12:18:23 -0500 Subject: commit: discard index after setting up partial commit There may still be some entries from the original index that should be discarded before we show the status. In particular, if a file was added in the index but not included in the partial commit, it would still show up in the status listing as staged for commit. Ultimately the correct fix is to keep the two states in separate index_state variables. Then we can avoid having to reload the cache from the temporary file altogether, and just point wt_status_print at the correct index. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin-commit.c | 4 ++++ t/t7502-status.sh | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/builtin-commit.c b/builtin-commit.c index a43f201995..45232a11c4 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -317,6 +317,10 @@ static char *prepare_index(int argc, const char **argv, const char *prefix) if (write_cache(fd, active_cache, active_nr) || close_lock_file(&false_lock)) die("unable to write temporary index file"); + + discard_cache(); + read_cache_from(false_lock.filename); + return false_lock.filename; } diff --git a/t/t7502-status.sh b/t/t7502-status.sh index b64ce30ff1..e00607490b 100755 --- a/t/t7502-status.sh +++ b/t/t7502-status.sh @@ -128,4 +128,25 @@ test_expect_success 'status without relative paths' ' ' +cat <expect +# On branch master +# Changes to be committed: +# (use "git reset HEAD ..." to unstage) +# +# modified: dir1/modified +# +# Untracked files: +# (use "git add ..." to include in what will be committed) +# +# dir1/untracked +# dir2/ +# expect +# output +# untracked +EOF +test_expect_success 'status of partial commit excluding new file in index' ' + git status dir1/modified >output && + diff -u expect output +' + test_done -- cgit v1.2.3