* Re: [PATCH v2 07/14] imap-send.c: inline imap_parse_list() in imap_list()
From: Michael Haggerty @ 2013-01-16 8:26 UTC (permalink / raw)
To: Matt Kraai; +Cc: Junio C Hamano, git
In-Reply-To: <20130115185147.GB14552@ftbfs.org>
On 01/15/2013 07:51 PM, Matt Kraai wrote:
> On Tue, Jan 15, 2013 at 09:06:25AM +0100, Michael Haggerty wrote:
>> -static struct imap_list *parse_imap_list(struct imap *imap, char **sp)
>> +static struct imap_list *parse_list(char **sp)
>
> The commit subject refers to imap_parse_list and imap_list whereas the
> code refers to parse_imap_list and parse_list.
Yes, you're right. Thanks.
Michael
--
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
^ permalink raw reply
* Re: [PATCH v2 06/14] imap-send.c: remove some unused fields from struct store
From: Michael Haggerty @ 2013-01-16 8:23 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Junio C Hamano, git, Jeff King
In-Reply-To: <20130115203204.GA12524@google.com>
On 01/15/2013 09:32 PM, Jonathan Nieder wrote:
> Michael Haggerty wrote:
>
>> - else if ((arg1 = next_arg(&cmd))) {
>> - if (!strcmp("EXISTS", arg1))
>> - ctx->gen.count = atoi(arg);
>> - else if (!strcmp("RECENT", arg1))
>> - ctx->gen.recent = atoi(arg);
>> + } else if ((arg1 = next_arg(&cmd))) {
>> + /* unused */
>
> The above is just the right thing to do to ensure no behavior change.
> Let's take a look at the resulting code, though:
>
> if (... various reasonable things ...) {
> ...
> } else if ((arg1 = next_arg(&cmd))) {
> /* unused */
> } else {
> fprintf(stderr, "IMAP error: unable to parse untagged response\n");
> return RESP_BAD;
>
> Anyone forced by some bug to examine this "/* unused */" case is going
> to have no clue what's going on. In that respect, the old code was
> much better, since it at least made it clear that one case where this
> code gets hit is handling "<num> EXISTS" and "<num> RECENT" untagged
> responses.
>
> I suspect that original code did not have an implicit and intended
> missing
>
> else
> ; /* negligible response; ignore it */
>
> but the intent was rather
>
> else {
> fprintf(stderr, "IMAP error: I can't parse this\n");
> return RESP_BAD;
> }
>
> Since actually fixing that is probably too aggressive for this patch,
> how about a FIXME comment like the following?
>
> /*
> * Unhandled response-data with at least two words.
> * Ignore it.
> *
> * NEEDSWORK: Previously this case handled '<num> EXISTS'
> * and '<num> RECENT' but as a probably-unintended side
> * effect it ignores other unrecognized two-word
> * responses. imap-send doesn't ever try to read
> * messages or mailboxes these days, so consider
> * eliminating this case.
> */
Yes, this sounds reasonable to me. Thanks for the improvement.
Michael
--
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
^ permalink raw reply
* Re: [PATCH] Allow custom "comment char"
From: Ralf Thielow @ 2013-01-16 8:17 UTC (permalink / raw)
To: Junio C Hamano; +Cc: jrnieder, git
In-Reply-To: <7vmww9zlwj.fsf@alter.siamese.dyndns.org>
2013/1/16 Junio C Hamano <gitster@pobox.com>:
>>> diff --git a/git-submodule.sh b/git-submodule.sh
>>> index 22ec5b6..1b8d95f 100755
>>> --- a/git-submodule.sh
>>> +++ b/git-submodule.sh
>>> @@ -975,13 +975,19 @@ cmd_summary() {
>>> echo
>>> done |
>>> if test -n "$for_status"; then
>>> + comment_char=`git config core.commentchar`
>>> + if [ ! -n "$comment_char" ]; then
>>> + comment_char='#'
>>> + elif [ ${#comment_char} -gt 1 ]; then
>>
>> Not portable, I think.
>>
>>> + echo "$comment_char"
>>> + sed -e "s|^|$comment_char |" -e "s|^$comment_char $|$comment_char|"
>>
>> Can $comment_char be a '|'?
>
> I think it may be the easiest to teach one of the pure-helper
> commands, e.g. "git stripspace", to do this kind of thing for you
> with a new option.
>
> To summarize, along the lines of the attached patch (on top of
> jc/custom-comment-char topic).
Very good idea. I'll integrate.
Thanks
^ permalink raw reply
* [PATCH v3 2/3] config: Introduce diff.algorithm variable
From: Michal Privoznik @ 2013-01-16 7:51 UTC (permalink / raw)
To: git; +Cc: gitster, trast, peff
In-Reply-To: <cover.1358322212.git.mprivozn@redhat.com>
Some users or projects prefer different algorithms over others, e.g.
patience over myers or similar. However, specifying appropriate
argument every time diff is to be used is impractical. Moreover,
creating an alias doesn't play nicely with other tools based on diff
(git-show for instance). Hence, a configuration variable which is able
to set specific algorithm is needed. For now, these four values are
accepted: 'myers' (which has the same effect as not setting the config
variable at all), 'minimal', 'patience' and 'histogram'.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
Documentation/diff-config.txt | 18 ++++++++++++++++++
contrib/completion/git-completion.bash | 1 +
diff.c | 24 ++++++++++++++++++++++++
3 files changed, 43 insertions(+)
diff --git a/Documentation/diff-config.txt b/Documentation/diff-config.txt
index 4314ad0..3a62ace 100644
--- a/Documentation/diff-config.txt
+++ b/Documentation/diff-config.txt
@@ -155,3 +155,21 @@ diff.tool::
"kompare". Any other value is treated as a custom diff tool,
and there must be a corresponding `difftool.<tool>.cmd`
option.
+
+diff.algorithm::
+ Choose a diff algorithm. The variants are as follows:
++
+--
+`default`, `myers`;;
+ The basic greedy diff algorithm. Currently, this happens to be
+ the default algorithm as well.
+`minimal`;;
+ Spend extra time to make sure the smallest possible diff is
+ produced.
+`patience`;;
+ Use "patience diff" algorithm when generating patches.
+`histogram`;;
+ This algorithm extends the patience algorithm to "support
+ low-occurrence common elements".
+--
++
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 383518c..33e25dc 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1839,6 +1839,7 @@ _git_config ()
diff.suppressBlankEmpty
diff.tool
diff.wordRegex
+ diff.algorithm
difftool.
difftool.prompt
fetch.recurseSubmodules
diff --git a/diff.c b/diff.c
index 348f71b..7d6cc4c 100644
--- a/diff.c
+++ b/diff.c
@@ -36,6 +36,7 @@ static int diff_no_prefix;
static int diff_stat_graph_width;
static int diff_dirstat_permille_default = 30;
static struct diff_options default_diff_options;
+static long diff_algorithm;
static char diff_colors[][COLOR_MAXLEN] = {
GIT_COLOR_RESET,
@@ -143,6 +144,21 @@ static int git_config_rename(const char *var, const char *value)
return git_config_bool(var,value) ? DIFF_DETECT_RENAME : 0;
}
+static long parse_algorithm_value(const char *value)
+{
+ if (!value)
+ return -1;
+ else if (!strcasecmp(value, "myers") || !strcasecmp(value, "default"))
+ return 0;
+ else if (!strcasecmp(value, "minimal"))
+ return XDF_NEED_MINIMAL;
+ else if (!strcasecmp(value, "patience"))
+ return XDF_PATIENCE_DIFF;
+ else if (!strcasecmp(value, "histogram"))
+ return XDF_HISTOGRAM_DIFF;
+ return -1;
+}
+
/*
* These are to give UI layer defaults.
* The core-level commands such as git-diff-files should
@@ -196,6 +212,13 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
return 0;
}
+ if (!strcmp(var, "diff.algorithm")) {
+ diff_algorithm = parse_algorithm_value(value);
+ if (diff_algorithm < 0)
+ return -1;
+ return 0;
+ }
+
if (git_color_config(var, value, cb) < 0)
return -1;
@@ -3213,6 +3236,7 @@ void diff_setup(struct diff_options *options)
options->add_remove = diff_addremove;
options->use_color = diff_use_color_default;
options->detect_rename = diff_detect_rename_default;
+ options->xdl_opts |= diff_algorithm;
if (diff_no_prefix) {
options->a_prefix = options->b_prefix = "";
--
1.8.0.2
^ permalink raw reply related
* [PATCH v3 0/3] Rework git-diff algorithm selection
From: Michal Privoznik @ 2013-01-16 7:51 UTC (permalink / raw)
To: git; +Cc: gitster, trast, peff
It's been a while I was trying to get this in. Recently, I realized how
important this is.
Please keep me CC'ed as I am not subscribed to the list.
diff to v1:
-Junio's suggestions worked in
diff to v2:
-yet more Junio's suggestions included
Michal Privoznik (3):
git-completion.bash: Autocomplete --minimal and --histogram for
git-diff
config: Introduce diff.algorithm variable
diff: Introduce --diff-algorithm command line option
Documentation/diff-config.txt | 18 ++++++++++++++++++
Documentation/diff-options.txt | 21 +++++++++++++++++++++
contrib/completion/git-completion.bash | 14 +++++++++++++-
diff.c | 34 ++++++++++++++++++++++++++++++++++
diff.h | 2 ++
merge-recursive.c | 9 +++++++++
6 files changed, 97 insertions(+), 1 deletion(-)
--
1.8.0.2
^ permalink raw reply
* [PATCH v3 1/3] git-completion.bash: Autocomplete --minimal and --histogram for git-diff
From: Michal Privoznik @ 2013-01-16 7:51 UTC (permalink / raw)
To: git; +Cc: gitster, trast, peff
In-Reply-To: <cover.1358322212.git.mprivozn@redhat.com>
Even though --patience was already there, we missed --minimal and
--histogram for some reason.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
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 a4c48e1..383518c 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1031,7 +1031,7 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
--no-ext-diff
--no-prefix --src-prefix= --dst-prefix=
--inter-hunk-context=
- --patience
+ --patience --histogram --minimal
--raw
--dirstat --dirstat= --dirstat-by-file
--dirstat-by-file= --cumulative
--
1.8.0.2
^ permalink raw reply related
* [PATCH v3 3/3] diff: Introduce --diff-algorithm command line option
From: Michal Privoznik @ 2013-01-16 7:51 UTC (permalink / raw)
To: git; +Cc: gitster, trast, peff
In-Reply-To: <cover.1358322212.git.mprivozn@redhat.com>
Since command line options have higher priority than config file
variables and taking previous commit into account, we need a way
how to specify myers algorithm on command line. However,
inventing `--myers` is not the right answer. We need far more
general option, and that is `--diff-algorithm`.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
Documentation/diff-options.txt | 21 +++++++++++++++++++++
contrib/completion/git-completion.bash | 11 +++++++++++
diff.c | 12 +++++++++++-
diff.h | 2 ++
merge-recursive.c | 9 +++++++++
5 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 39f2c50..6f11c34 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -55,6 +55,27 @@ endif::git-format-patch[]
--histogram::
Generate a diff using the "histogram diff" algorithm.
+--diff-algorithm={patience|minimal|histogram|myers}::
+ Choose a diff algorithm. The variants are as follows:
++
+--
+`default`, `myers`;;
+ The basic greedy diff algorithm. Currently, this happens to be
+ the default algorithm as well.
+`minimal`;;
+ Spend extra time to make sure the smallest possible diff is
+ produced.
+`patience`;;
+ Use "patience diff" algorithm when generating patches.
+`histogram`;;
+ This algorithm extends the patience algorithm to "support
+ low-occurrence common elements".
+--
++
+For instance, if you configured diff.algorithm variable to a
+non-default value and want to use the default one, then you
+have to use `--diff-algorithm=default` option.
+
--stat[=<width>[,<name-width>[,<count>]]]::
Generate a diffstat. By default, as much space as necessary
will be used for the filename part, and the rest for the graph
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 33e25dc..d592cf9 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1021,6 +1021,8 @@ _git_describe ()
__gitcomp_nl "$(__git_refs)"
}
+__git_diff_algorithms="myers minimal patience histogram"
+
__git_diff_common_options="--stat --numstat --shortstat --summary
--patch-with-stat --name-only --name-status --color
--no-color --color-words --no-renames --check
@@ -1035,6 +1037,7 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
--raw
--dirstat --dirstat= --dirstat-by-file
--dirstat-by-file= --cumulative
+ --diff-algorithm=
"
_git_diff ()
@@ -1042,6 +1045,10 @@ _git_diff ()
__git_has_doubledash && return
case "$cur" in
+ --diff-algorithm=*)
+ __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
+ return
+ ;;
--*)
__gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
--base --ours --theirs --no-index
@@ -2114,6 +2121,10 @@ _git_show ()
" "" "${cur#*=}"
return
;;
+ --diff-algorithm=*)
+ __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
+ return
+ ;;
--*)
__gitcomp "--pretty= --format= --abbrev-commit --oneline
$__git_diff_common_options
diff --git a/diff.c b/diff.c
index 7d6cc4c..5fa40e9 100644
--- a/diff.c
+++ b/diff.c
@@ -144,7 +144,7 @@ static int git_config_rename(const char *var, const char *value)
return git_config_bool(var,value) ? DIFF_DETECT_RENAME : 0;
}
-static long parse_algorithm_value(const char *value)
+long parse_algorithm_value(const char *value)
{
if (!value)
return -1;
@@ -3634,6 +3634,16 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);
else if (!strcmp(arg, "--histogram"))
options->xdl_opts = DIFF_WITH_ALG(options, HISTOGRAM_DIFF);
+ else if (!prefixcmp(arg, "--diff-algorithm=")) {
+ long value = parse_algorithm_value(arg+17);
+ if (value < 0)
+ return error("option diff-algorithm accepts \"myers\", "
+ "\"minimal\", \"patience\" and \"histogram\"");
+ /* clear out previous settings */
+ DIFF_XDL_CLR(options, NEED_MINIMAL);
+ options->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;
+ options->xdl_opts |= value;
+ }
/* flags options */
else if (!strcmp(arg, "--binary")) {
diff --git a/diff.h b/diff.h
index a47bae4..54c2590 100644
--- a/diff.h
+++ b/diff.h
@@ -333,6 +333,8 @@ extern struct userdiff_driver *get_textconv(struct diff_filespec *one);
extern int parse_rename_score(const char **cp_p);
+extern long parse_algorithm_value(const char *value);
+
extern int print_stat_summary(FILE *fp, int files,
int insertions, int deletions);
extern void setup_diff_pager(struct diff_options *);
diff --git a/merge-recursive.c b/merge-recursive.c
index 33ba5dc..ea9dbd3 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -2068,6 +2068,15 @@ int parse_merge_opt(struct merge_options *o, const char *s)
o->xdl_opts = DIFF_WITH_ALG(o, PATIENCE_DIFF);
else if (!strcmp(s, "histogram"))
o->xdl_opts = DIFF_WITH_ALG(o, HISTOGRAM_DIFF);
+ else if (!strcmp(s, "diff-algorithm=")) {
+ long value = parse_algorithm_value(s+15);
+ if (value < 0)
+ return -1;
+ /* clear out previous settings */
+ DIFF_XDL_CLR(o, NEED_MINIMAL);
+ o->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;
+ o->xdl_opts |= value;
+ }
else if (!strcmp(s, "ignore-space-change"))
o->xdl_opts |= XDF_IGNORE_WHITESPACE_CHANGE;
else if (!strcmp(s, "ignore-all-space"))
--
1.8.0.2
^ permalink raw reply related
* Re: [PATCH] Allow custom "comment char"
From: Junio C Hamano @ 2013-01-16 6:23 UTC (permalink / raw)
To: Ralf Thielow; +Cc: jrnieder, git
In-Reply-To: <7v622y45wy.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> Ralf Thielow <ralf.thielow@gmail.com> writes:
> ...
> Looks like a good progress overall, except for nits here and there.
>
>> diff --git a/builtin/notes.c b/builtin/notes.c
>> index 453457a..5e84e35 100644
>> --- a/builtin/notes.c
>> +++ b/builtin/notes.c
>> @@ -92,10 +92,7 @@ static const char * const git_notes_get_ref_usage[] = {
>> };
>>
>> static const char note_template[] =
>> - "\n"
>> - "#\n"
>> - "# Write/edit the notes for the following object:\n"
>> - "#\n";
>> + "Write/edit the notes for the following object:";
>
> I think this (and its use site that manually adds "\n#\n") is a
> symptom of strbuf_commented_add*() function not designed right.
> When it iterates over lines and adds each of them in a commented out
> form, it could check if the line is an empty one and refrain from
> adding a trailing SP if that is the case. Then this can become
>
> "\nWrite/edit the notes...\n\n";
>
> You have to create the "\n" blank line at the beginning manually,
> but that is logically outside the commented out block, so it is not
> a problem.
>> diff --git a/git-submodule.sh b/git-submodule.sh
>> index 22ec5b6..1b8d95f 100755
>> --- a/git-submodule.sh
>> +++ b/git-submodule.sh
>> @@ -975,13 +975,19 @@ cmd_summary() {
>> echo
>> done |
>> if test -n "$for_status"; then
>> + comment_char=`git config core.commentchar`
>> + if [ ! -n "$comment_char" ]; then
>> + comment_char='#'
>> + elif [ ${#comment_char} -gt 1 ]; then
>
> Not portable, I think.
>
>> + echo "$comment_char"
>> + sed -e "s|^|$comment_char |" -e "s|^$comment_char $|$comment_char|"
>
> Can $comment_char be a '|'?
I think it may be the easiest to teach one of the pure-helper
commands, e.g. "git stripspace", to do this kind of thing for you
with a new option.
To summarize, along the lines of the attached patch (on top of
jc/custom-comment-char topic).
builtin/branch.c | 20 +++++++++-----------
builtin/stripspace.c | 35 +++++++++++++++++++++++++++++------
strbuf.c | 42 +++++++++++++++++++++++++++++++++++++++++-
strbuf.h | 4 ++++
4 files changed, 83 insertions(+), 18 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index 7f8865a..42de4c5 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -707,18 +707,16 @@ static int edit_branch_description(const char *branch_name)
if (!buf.len || buf.buf[buf.len-1] != '\n')
strbuf_addch(&buf, '\n');
/*
- * NEEDSWORK: introduce a strbuf_commented_addf(), possibly
- * sharing code with status_vprintf(), that makes each line
- * commented with comment_line_char, and use it here and from
- * other places (e.g. write_commented_object() and create_note()
- * in builtin/notes.c and create_tag() in builtin/tag.c).
+ * NEEDSWORK: convert more code to use this:
+ * (e.g. write_commented_object() and create_note() in
+ * builtin/notes.c and create_tag() in builtin/tag.c).
*/
- strbuf_addf(&buf,
- "%c Please edit the description for the branch\n"
- "%c %s\n"
- "%c Lines starting with '%c' will be stripped.\n",
- comment_line_char, comment_line_char,
- branch_name, comment_line_char, comment_line_char);
+ strbuf_commented_addf(&buf,
+ "Please edit the description for the branch\n"
+ " %s\n"
+ "Lines starting with '%c' will be stripped.\n",
+ branch_name, comment_line_char);
+
fp = fopen(git_path(edit_description), "w");
if ((fwrite(buf.buf, 1, buf.len, fp) < buf.len) || fclose(fp)) {
strbuf_release(&buf);
diff --git a/builtin/stripspace.c b/builtin/stripspace.c
index 600ca66..790b500 100644
--- a/builtin/stripspace.c
+++ b/builtin/stripspace.c
@@ -66,21 +66,44 @@ void stripspace(struct strbuf *sb, int skip_comments)
strbuf_setlen(sb, j);
}
+static void comment_lines(struct strbuf *buf)
+{
+ char *msg;
+ size_t len;
+
+ msg = strbuf_detach(buf, &len);
+ strbuf_add_commented_lines(buf, msg, len);
+}
+
int cmd_stripspace(int argc, const char **argv, const char *prefix)
{
struct strbuf buf = STRBUF_INIT;
int strip_comments = 0;
+ enum { INVAL = 0, STRIP_SPACE = 1, COMMENT_LINES = 2 } mode = STRIP_SPACE;
+
+ if (argc == 2) {
+ if (!strcmp(argv[1], "-s") ||
+ !strcmp(argv[1], "--strip-comments")) {
+ strip_comments = 1;
+ } else if (!strcmp(argv[1], "-c")) {
+ mode = COMMENT_LINES;
+ git_config(git_default_config, NULL);
+ } else {
+ mode = INVAL;
+ }
+ } else if (argc > 1)
+ mode = INVAL;
- if (argc == 2 && (!strcmp(argv[1], "-s") ||
- !strcmp(argv[1], "--strip-comments")))
- strip_comments = 1;
- else if (argc > 1)
- usage("git stripspace [-s | --strip-comments] < input");
+ if (mode == INVAL)
+ usage("git stripspace [-s|-c] <input");
if (strbuf_read(&buf, 0, 1024) < 0)
die_errno("could not read the input");
- stripspace(&buf, strip_comments);
+ if (mode == STRIP_SPACE)
+ stripspace(&buf, strip_comments);
+ else /* i.e. COMMENT_LINES */
+ comment_lines(&buf);
write_or_die(1, buf.buf, buf.len);
strbuf_release(&buf);
diff --git a/strbuf.c b/strbuf.c
index 9a373be..d0525c8 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -411,12 +411,17 @@ int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint)
return len;
}
-void strbuf_add_lines(struct strbuf *out, const char *prefix,
+static void add_lines(struct strbuf *out,
+ const char *prefix1,
+ const char *prefix2,
const char *buf, size_t size)
{
while (size) {
+ const char *prefix;
const char *next = memchr(buf, '\n', size);
next = next ? (next + 1) : (buf + size);
+
+ prefix = (prefix2 && buf[0] == '\n') ? prefix2 : prefix1;
strbuf_addstr(out, prefix);
strbuf_add(out, buf, next - buf);
size -= next - buf;
@@ -425,6 +430,41 @@ void strbuf_add_lines(struct strbuf *out, const char *prefix,
strbuf_complete_line(out);
}
+void strbuf_add_lines(struct strbuf *out, const char *prefix,
+ const char *buf, size_t size)
+{
+ add_lines(out, prefix, NULL, buf, size);
+}
+
+void strbuf_add_commented_lines(struct strbuf *out,
+ const char *buf, size_t size)
+{
+ static char prefix1[3];
+ static char prefix2[2];
+
+ if (prefix1[0] != comment_line_char) {
+ sprintf(prefix1, "%c ", comment_line_char);
+ sprintf(prefix2, "%c", comment_line_char);
+ }
+ add_lines(out, prefix1, prefix2, buf, size);
+}
+
+void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...)
+{
+ va_list params;
+ struct strbuf buf = STRBUF_INIT;
+ int incomplete_line = sb->len && sb->buf[sb->len - 1] != '\n';
+
+ va_start(params, fmt);
+ strbuf_vaddf(&buf, fmt, params);
+ va_end(params);
+
+ strbuf_add_commented_lines(sb, buf.buf, buf.len);
+ if (incomplete_line)
+ sb->buf[--sb->len] = '\0';
+ strbuf_release(&buf);
+}
+
void strbuf_addstr_xml_quoted(struct strbuf *buf, const char *s)
{
while (*s) {
diff --git a/strbuf.h b/strbuf.h
index ecae4e2..1eb0c75 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -131,10 +131,14 @@ extern void strbuf_addbuf_percentquote(struct strbuf *dst, const struct strbuf *
__attribute__((format (printf,2,3)))
extern void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
+__attribute__((format (printf,2,3)))
+extern void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...);
__attribute__((format (printf,2,0)))
extern void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap);
extern void strbuf_add_lines(struct strbuf *sb, const char *prefix, const char *buf, size_t size);
+extern void strbuf_add_commented_lines(struct strbuf *out, const char *buf, size_t size);
+
/*
* Append s to sb, with the characters '<', '>', '&' and '"' converted
^ permalink raw reply related
* Re: t9902 fails (Was: [PATCH] attr: fix off-by-one directory component length calculation)
From: Torsten Bögershausen @ 2013-01-16 6:15 UTC (permalink / raw)
To: Jeff King
Cc: Jean-Noël AVILA, Junio C Hamano, git,
Nguyễn Thái Ngọc Duy, Torsten Bögershausen
In-Reply-To: <20130115232400.GA16147@sigill.intra.peff.net>
On 01/16/2013 12:24 AM, Jeff King wrote:
> On Tue, Jan 15, 2013 at 12:49:05PM -0800, Junio C Hamano wrote:
>
>> "Jean-Noël AVILA"<avila.jn@gmail.com> writes:
>>
>>> Btw, the test 10 to t9902 is failing on my Debian testing. Is it a known
>>> issue?
>>
>> Which branch?
>
> t9902.10 is overly sensitive to extra git commands in your PATH, as well
> as cruft in your build dir (especially if you have been building 'pu',
> which has git-check-ignore). Try "make clean&& make test".
>
> -Peff
This may help, or it may not.
If there are other binaries like
"git-check-email" or "git-check-ignore" in the PATH
.....
When you switch to a branch generating a file like
git-check-ignore then "make clean" will know about it
and will remove it.
If you switch to master, then "make clean" will not remove it.
What does "git status" say?
We had a discussion about this some weeks ago, but never concluded.
How about this:
http://comments.gmane.org/gmane.comp.version-control.git/211907
^ permalink raw reply
* Re: [PATCH] attr: fix off-by-one directory component length calculation
From: Duy Nguyen @ 2013-01-16 6:02 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jean-Noël AVILA, git
In-Reply-To: <7vtxqhzo4m.fsf@alter.siamese.dyndns.org>
On Tue, Jan 15, 2013 at 09:35:21PM -0800, Junio C Hamano wrote:
> >> Also the original only
> >> scanned the string from the beginning once (instead of letting
> >> strlen() to scan once and go back).
> >
> > But we do need to strlen() anyway in collect_all_attrs().
>
> That is exactly my point, isn't it?
OK I get your point now. Something like this?
-- 8< --
Subject: [PATCH] attr: avoid calling find_basename() twice per path
find_basename() is only used inside collect_all_attrs(), called once
in prepare_attr_stack, then again after prepare_attr_stack()
returns. Both calls return exact same value. Reorder the code to do
the same task once. Also avoid strlen() because we knows the length
after finding basename.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
attr.c | 45 ++++++++++++++++++---------------------------
1 file changed, 18 insertions(+), 27 deletions(-)
diff --git a/attr.c b/attr.c
index cfc6748..880f862 100644
--- a/attr.c
+++ b/attr.c
@@ -564,32 +564,12 @@ static void bootstrap_attr_stack(void)
attr_stack = elem;
}
-static const char *find_basename(const char *path)
-{
- const char *cp, *last_slash = NULL;
-
- for (cp = path; *cp; cp++) {
- if (*cp == '/' && cp[1])
- last_slash = cp;
- }
- return last_slash ? last_slash + 1 : path;
-}
-
-static void prepare_attr_stack(const char *path)
+static void prepare_attr_stack(const char *path, int dirlen)
{
struct attr_stack *elem, *info;
- int dirlen, len;
+ int len;
const char *cp;
- dirlen = find_basename(path) - path;
-
- /*
- * find_basename() includes the trailing slash, but we do
- * _not_ want it.
- */
- if (dirlen)
- dirlen--;
-
/*
* At the bottom of the attribute stack is the built-in
* set of attribute definitions, followed by the contents
@@ -769,15 +749,26 @@ static int macroexpand_one(int attr_nr, int rem)
static void collect_all_attrs(const char *path)
{
struct attr_stack *stk;
- int i, pathlen, rem;
- const char *basename;
+ int i, pathlen, rem, dirlen;
+ const char *basename, *cp, *last_slash = NULL;
+
+ for (cp = path; *cp; cp++) {
+ if (*cp == '/' && cp[1])
+ last_slash = cp;
+ }
+ pathlen = cp - path;
+ if (last_slash) {
+ basename = last_slash + 1;
+ dirlen = last_slash - path;
+ } else {
+ basename = path;
+ dirlen = 0;
+ }
- prepare_attr_stack(path);
+ prepare_attr_stack(path, dirlen);
for (i = 0; i < attr_nr; i++)
check_all_attr[i].value = ATTR__UNKNOWN;
- basename = find_basename(path);
- pathlen = strlen(path);
rem = attr_nr;
for (stk = attr_stack; 0 < rem && stk; stk = stk->prev)
rem = fill(path, pathlen, basename, stk, rem);
--
1.8.0.rc3.18.g0d9b108
-- 8< --
^ permalink raw reply related
* git fetch without --recurse-submodules option
From: 乙酸鋰 @ 2013-01-16 5:45 UTC (permalink / raw)
To: git
Hi,
With git pull or git fetch without specifying --recurse-submodules,
what is the default action?
It seems git fetches submodules wtihout specifying --recurse-submodules.
If this is not clear, please update documentation.
In git pull document --recurse-submodules option, it tells users to
see git-config(1) and gitmodules(5), but does not tell users to refer
to git fetch --recurse-submodules for the meaning of the switches.
In git fetch document --recurse-submodules option, it does not tell
users to see git-config(1) or gitmodules(5).
^ permalink raw reply
* Re: [PATCH] attr: fix off-by-one directory component length calculation
From: Junio C Hamano @ 2013-01-16 5:35 UTC (permalink / raw)
To: Duy Nguyen; +Cc: Jean-Noël AVILA, git
In-Reply-To: <CACsJy8C2uEgwozpWBfowYJea3XRB72rhzjsSFuG9Ud0afuQy6w@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> writes:
> On Wed, Jan 16, 2013 at 9:33 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> Duy Nguyen <pclouds@gmail.com> writes:
>>
>>> On Wed, Jan 16, 2013 at 08:08:03AM +0700, Duy Nguyen wrote:
>>>> Actually I'd like to remove that function.
>>>
>>> This is what I had in mind:
>>
>> I think the replacement logic to find the basename is moderately
>> inferiour to the original. For one thing (this may be somewhat
>> subjective), it is less readable now.
>
> Yeah, maybe it's micro optimization.
Your change is micro unoptimization (and making the result less
readable). I wouldn't worry too much about micro-optimizing an
existing piece of code, but making an efficient code into a worse
one without a good reason is a different story.
>> Also the original only
>> scanned the string from the beginning once (instead of letting
>> strlen() to scan once and go back).
>
> But we do need to strlen() anyway in collect_all_attrs().
That is exactly my point, isn't it?
The loop to find the basename has to run to the end of the string at
least once, as it cannot not stop at the last slash---it goes from
front to back and it won't know which one is the last slash until it
sees the end of the string. After the loop exits, you know the
length of the string without running a separate strlen() to assign
to "pathlen".
> So we scan
> the string 3 times (strlen + 2 * find_basename) in the original. Now
> we do it twice.
I already said that overall restructure of the code may be a good
idea to reduce the calls to the function. I was only comparing the
implementations of the loop that finds the basename, so I do not
understand what you mean by that "2 *" in that comparison. It does
not make sense to me.
^ permalink raw reply
* Re: [PATCH 3/7] contrib/subtree: Add --unannotate
From: Junio C Hamano @ 2013-01-16 4:31 UTC (permalink / raw)
To: greened; +Cc: git, James Nylen
In-Reply-To: <87y5ftojoj.fsf@waller.obbligato.org>
greened@obbligato.org writes:
> greened@obbligato.org writes:
>
>>> I think this paragraph inherits existing breakage from the beginning
>>> of time, but I do not think the above will format the second and
>>> subsequent paragraphs correctly.
>>
>> Ok, I'll take a look.
>
> I don't know what "correctly" is but it is at least formatted in a
> similar manner to the other options.
That is what "inherits existing breakage" means ;-)
The first paragraph is typeset as body text, while the rest are
typeset in monospaced font, no?
It should be more like this, I think:
--option::
First paragraph
+
Second paragraph
+
And third paragraph
^ permalink raw reply
* Re: [PATCH 3/7] contrib/subtree: Add --unannotate
From: greened @ 2013-01-16 4:06 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, James Nylen
In-Reply-To: <87vcaxq0ez.fsf@waller.obbligato.org>
greened@obbligato.org writes:
>> I think this paragraph inherits existing breakage from the beginning
>> of time, but I do not think the above will format the second and
>> subsequent paragraphs correctly.
>
> Ok, I'll take a look.
I don't know what "correctly" is but it is at least formatted in a
similar manner to the other options.
-David
^ permalink raw reply
* Re: [PATCH 0/7] guilt patches, including git 1.8 support
From: Theodore Ts'o @ 2013-01-16 3:26 UTC (permalink / raw)
To: Jonathan Nieder
Cc: Josef 'Jeff' Sipek, git, Per Cederqvist, Iulian Udrea,
Axel Beckert
In-Reply-To: <20130116022606.GI12524@google.com>
On Tue, Jan 15, 2013 at 06:26:06PM -0800, Jonathan Nieder wrote:
> Hi Jeff and other guilty parties,
>
> I collected all the guilt patches I could find on-list and added one
> of my own. Completely untested, except for running the regression
> tests. These are also available via git protocol from
>
> git://repo.or.cz/guilt/mob.git mob
Jonathan, thanks for collecting all of the guilt patches! Your repro
was also very much really useful since I hadn't grabbed the latest
patches from jeffpc's repo before it disappeared after the kernel.org
security shutdown.
Jeff, do you need some help getting your repro on kernel.org
re-established?
- Ted
^ permalink raw reply
* Re: [PATCH 4/7] contrib/subtree: Better Error Handling for add
From: greened @ 2013-01-16 3:21 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7v7gnneco2.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> "David A. Greene" <greened@obbligato.org> writes:
>
>> From: "David A. Greene" <greened@obbligato.org>
>>
>> Check refspecs for validity before passing them on to other commands.
>> This lets us generate more helpful error messages.
>>
>> Signed-off-by: David A. Greene <greened@obbligato.org>
>> ---
>> contrib/subtree/git-subtree.sh | 12 +++++++++---
>> 1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
>> index cac0680..d53eaee 100755
>> --- a/contrib/subtree/git-subtree.sh
>> +++ b/contrib/subtree/git-subtree.sh
>> @@ -508,12 +508,18 @@ cmd_add()
>> ensure_clean
>>
>> if [ $# -eq 1 ]; then
>> - "cmd_add_commit" "$@"
>> + git rev-parse -q --verify "$1^{commit}" >/dev/null ||
>> + die "'$1' does not refer to a commit"
>
> Where do these uneven indentation come from? Is it mimicking
> existing breakage in the script?
Huh. I'm not sure how that happened. I'll fix it if you haven't got to
it already.
-David
^ permalink raw reply
* Re: [PATCH 3/7] contrib/subtree: Add --unannotate
From: greened @ 2013-01-16 3:20 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, James Nylen
In-Reply-To: <7vehhvecoy.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> "David A. Greene" <greened@obbligato.org> writes:
>
>> diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
>> index c5bce41..75aa690 100644
>> --- a/contrib/subtree/git-subtree.txt
>> +++ b/contrib/subtree/git-subtree.txt
>> @@ -198,6 +198,21 @@ OPTIONS FOR split
>> git subtree tries to make it work anyway, particularly
>> if you use --rejoin, but it may not always be effective.
>>
>> +--unannotate=<annotation>::
>> + This option is only valid for the split command.
>> +
>> + When generating synthetic history, try to remove the prefix
>> + <annotation> from each commit message (using bash's "strip
>> + shortest match from beginning" command, which supports
>> + globbing). This makes sense if you format library commits
>> + like "library: Change something or other" when you're working
>> + in your project's repository, but you want to remove this
>> + prefix when pushing back to the library's upstream repository.
>> + (In this case --unannotate='*: ' would work well.)
>> +
>> + Like --annotate, you need to use the same <annotation>
>> + whenever you split, or you may run into problems.
>
> I think this paragraph inherits existing breakage from the beginning
> of time, but I do not think the above will format the second and
> subsequent paragraphs correctly.
Ok, I'll take a look.
> I've applied all seven patches in the series with minor fix-ups, and
> will merge it to 'pu'.
Thanks!
-David
^ permalink raw reply
* Re: [PATCH 2/7] contrib/subtree: Use %B for Split Subject/Body
From: greened @ 2013-01-16 3:18 UTC (permalink / raw)
To: Junio C Hamano; +Cc: 郑文辉(Techlive Zheng), git
In-Reply-To: <7vzk0j9oig.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> David, how would you like to handle a reroll of this piece?
I'll just get the test fix from Techlive Zheng, apply it to my
branch and re-send.
Are you incorporating the other patches? Should I drop them
from my list?
-David
^ permalink raw reply
* Re: [PATCH 2/7] contrib/subtree: Use %B for Split Subject/Body
From: greened @ 2013-01-16 3:14 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Techlive Zheng
In-Reply-To: <7vmwwjedei.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> "David A. Greene" <greened@obbligato.org> writes:
>
>> From: Techlive Zheng <techlivezheng@gmail.com>
>>
>> Use %B to format the commit message and body to avoid an extra newline
>> if a commit only has a subject line.
>>
>> Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>
>>
>> Signed-off-by: David A. Greene <greened@obbligato.org>
>> ---
>
> This time (only), I'll try to fix them up at my end, but please
> check your toolchain, find out where the extra blank line between
> S-o-b: lines we see above come from, and fix that, so that I won't
> have to do so again.
Will do.
>> contrib/subtree/git-subtree.sh | 6 +++++-
>> contrib/subtree/t/t7900-subtree.sh | 15 +++++++++++++++
>> 2 files changed, 20 insertions(+), 1 deletion(-)
>>
>> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
>> index 920c664..5341b36 100755
>> --- a/contrib/subtree/git-subtree.sh
>> +++ b/contrib/subtree/git-subtree.sh
>> @@ -296,7 +296,11 @@ copy_commit()
>> # We're going to set some environment vars here, so
>> # do it in a subshell to get rid of them safely later
>> debug copy_commit "{$1}" "{$2}" "{$3}"
>> - git log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%s%n%n%b' "$1" |
>> + # Use %B rather than %s%n%n%b to handle the special case of a
>> + # commit that only has a subject line. We don't want to
>> + # introduce a newline after the subject, causing generation of
>> + # a new hash.
>> + git log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%B' "$1" |
>
> The new format template is fine, but I do not think the comment
> should be there. It does not give any useful information to people
> who are reading the end result of applying this patch and is useful
> only in the context of comparing the old and new templates, iow, it
> belongs to the commit log message.
I'll delete the comment.
-David
^ permalink raw reply
* Re: [PATCH] attr: fix off-by-one directory component length calculation
From: Duy Nguyen @ 2013-01-16 3:12 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jean-Noël AVILA, git
In-Reply-To: <7vbocp26xa.fsf@alter.siamese.dyndns.org>
On Wed, Jan 16, 2013 at 9:33 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Duy Nguyen <pclouds@gmail.com> writes:
>
>> On Wed, Jan 16, 2013 at 08:08:03AM +0700, Duy Nguyen wrote:
>>> Actually I'd like to remove that function.
>>
>> This is what I had in mind:
>
> I think the replacement logic to find the basename is moderately
> inferiour to the original. For one thing (this may be somewhat
> subjective), it is less readable now.
Yeah, maybe it's micro optimization.
> Also the original only
> scanned the string from the beginning once (instead of letting
> strlen() to scan once and go back).
But we do need to strlen() anyway in collect_all_attrs(). So we scan
the string 3 times (strlen + 2 * find_basename) in the original. Now
we do it twice
--
Duy
^ permalink raw reply
* Re: [PATCH 0/3] Update HTTPD/daemon tests for new push.default
From: Junio C Hamano @ 2013-01-16 2:39 UTC (permalink / raw)
To: Brian Gernhardt; +Cc: Git List
In-Reply-To: <cover.1358301792.git.brian@gernhardtsoftware.com>
These are tests that I do not usually run myself.
Thanks for catching and correcting them.
^ permalink raw reply
* Re: What's cooking in git.git (Jan 2013, #06; Mon, 14)
From: Junio C Hamano @ 2013-01-16 2:37 UTC (permalink / raw)
To: Adam Spiers; +Cc: git
In-Reply-To: <CAOkDyE_a4R7=A318VL2TxDn6X8Tu2+m2KNWWYqwBbygRrALQzg@mail.gmail.com>
Adam Spiers <git@adamspiers.org> writes:
> On Mon, Jan 14, 2013 at 10:23 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> * as/check-ignore (2013-01-10) 12 commits
>> (merged to 'next' on 2013-01-14 at 9df2afc)
>> + t0008: avoid brace expansion
>> + add git-check-ignore sub-command
>> + setup.c: document get_pathspec()
>> + add.c: extract new die_if_path_beyond_symlink() for reuse
>> + add.c: extract check_path_for_gitlink() from treat_gitlinks() for reuse
>> + pathspec.c: rename newly public functions for clarity
>> + add.c: move pathspec matchers into new pathspec.c for reuse
>> + add.c: remove unused argument from validate_pathspec()
>> + dir.c: improve docs for match_pathspec() and match_pathspec_depth()
>> + dir.c: provide clear_directory() for reclaiming dir_struct memory
>> + dir.c: keep track of where patterns came from
>> + dir.c: use a single struct exclude_list per source of excludes
>>
>> Add a new command "git check-ignore" for debugging .gitignore
>> files.
>
> The above is v4 plus the "t0008: avoid brace expansion" fix. v4 is
> slightly outdated and not quite the right version to merge to 'next'.
Sigh.
The "What's cooking" is a report of what _has_ already happened. I
would have appreciated if you said the above _before_ this happened.
> I'll post a v5 re-roll as per:
Now the series is in 'next', it is too late to _replace_ it X-<.
Could you instead make an incremental updates on top? That way, we
do not have to re-review the whole thing; we only need to review the
changes relative to the old one, making sure that the fixes in the
updates are better than the v4 version.
Thanks.
^ permalink raw reply
* Re: [PATCH] attr: fix off-by-one directory component length calculation
From: Junio C Hamano @ 2013-01-16 2:33 UTC (permalink / raw)
To: Duy Nguyen; +Cc: Jean-Noël AVILA, git
In-Reply-To: <20130116020901.GA1041@duynguyen-vnpc.dek-tpc.internal>
Duy Nguyen <pclouds@gmail.com> writes:
> On Wed, Jan 16, 2013 at 08:08:03AM +0700, Duy Nguyen wrote:
>> Actually I'd like to remove that function.
>
> This is what I had in mind:
I think the replacement logic to find the basename is moderately
inferiour to the original. For one thing (this may be somewhat
subjective), it is less readable now. Also the original only
scanned the string from the beginning once (instead of letting
strlen() to scan once and go back).
The new code structure to inline the basename finding part and to
pass the dirlen down the callchain may make sense, though.
>> -- 8< --
> Subject: [PATCH] attr: avoid calling find_basename() twice per path
>
> find_basename() is only used inside collect_all_attrs(), called once
> in prepare_attr_stack, then again after prepare_attr_stack()
> returns. Both calls return exact same value. Reorder the code to do it
> once.
>
> While at it, make use of "pathlen" to stop searching early if
> possible.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> attr.c | 46 +++++++++++++++++++---------------------------
> 1 file changed, 19 insertions(+), 27 deletions(-)
>
> diff --git a/attr.c b/attr.c
> index cfc6748..04cb9a0 100644
> --- a/attr.c
> +++ b/attr.c
> @@ -564,32 +564,12 @@ static void bootstrap_attr_stack(void)
> attr_stack = elem;
> }
>
> -static const char *find_basename(const char *path)
> -{
> - const char *cp, *last_slash = NULL;
> -
> - for (cp = path; *cp; cp++) {
> - if (*cp == '/' && cp[1])
> - last_slash = cp;
> - }
> - return last_slash ? last_slash + 1 : path;
> -}
> -
> -static void prepare_attr_stack(const char *path)
> +static void prepare_attr_stack(const char *path, int dirlen)
> {
> struct attr_stack *elem, *info;
> - int dirlen, len;
> + int len;
> const char *cp;
>
> - dirlen = find_basename(path) - path;
> -
> - /*
> - * find_basename() includes the trailing slash, but we do
> - * _not_ want it.
> - */
> - if (dirlen)
> - dirlen--;
> -
> /*
> * At the bottom of the attribute stack is the built-in
> * set of attribute definitions, followed by the contents
> @@ -769,15 +749,27 @@ static int macroexpand_one(int attr_nr, int rem)
> static void collect_all_attrs(const char *path)
> {
> struct attr_stack *stk;
> - int i, pathlen, rem;
> - const char *basename;
> + int i, pathlen, rem, dirlen = 0;
> + const char *basename = path, *cp;
>
> - prepare_attr_stack(path);
> + pathlen = strlen(path);
> +
> + /*
> + * This loop is similar to strrchr(path, '/') except that the
> + * trailing slash is skipped.
> + */
> + for (cp = path + pathlen - 2; cp >= path; cp--) {
> + if (*cp == '/') {
> + basename = cp + 1;
> + dirlen = cp - path;
> + break;
> + }
> + }
> +
> + prepare_attr_stack(path, dirlen);
> for (i = 0; i < attr_nr; i++)
> check_all_attr[i].value = ATTR__UNKNOWN;
>
> - basename = find_basename(path);
> - pathlen = strlen(path);
> rem = attr_nr;
> for (stk = attr_stack; 0 < rem && stk; stk = stk->prev)
> rem = fill(path, pathlen, basename, stk, rem);
^ permalink raw reply
* [GUILT] [PATCH 7/7] Drop unneeded git version check.
From: Jonathan Nieder @ 2013-01-16 2:31 UTC (permalink / raw)
To: Josef 'Jeff' Sipek
Cc: git, Per Cederqvist, Theodore Ts'o, Iulian Udrea,
Axel Beckert
In-Reply-To: <20130116022606.GI12524@google.com>
Git's compatibility record is pretty good, so there's no need to worry
that newer versions of git will break the "git config" command.
Without this change, guilt errors out for git 1.8. With it, all tests
pass.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Thanks for reading.
guilt | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/guilt b/guilt
index 66a671a..6cb43e3 100755
--- a/guilt
+++ b/guilt
@@ -26,17 +26,6 @@ SUBDIRECTORY_OK=1
. "$(git --exec-path)/git-sh-setup"
#
-# Git version check
-#
-gitver=`git --version | cut -d' ' -f3 | sed -e 's/^debian\.//'`
-case "$gitver" in
- 1.5.*) ;; # git config
- 1.6.*) ;; # git config
- 1.7.*) ;; # git config
- *) die "Unsupported version of git ($gitver)" ;;
-esac
-
-#
# Shell library
#
usage()
--
1.8.1
^ permalink raw reply related
* [GUILT] [PATCH 6/7] Change git branch when patches are applied.
From: Jonathan Nieder @ 2013-01-16 2:30 UTC (permalink / raw)
To: Josef 'Jeff' Sipek
Cc: git, Per Cederqvist, Theodore Ts'o, Iulian Udrea,
Axel Beckert
In-Reply-To: <20130116022606.GI12524@google.com>
From: Per Cederqvist <cederp@opera.com>
Date: Mon, 30 Apr 2012 12:24:06 +0200
Apply patches on a separate branch. The separate branch is
automatically created when Guilt pushes something, and removed when no
patches are applied. The name is formed by prepending "guilt/" to the
original branch.
This breaks the "upstream" relationship, so a mistaken "git push"
while patches are applied will no longer mess up your upstream
repository.
Update the testsuite and documentation.
Thanks to Junio C Hamano for suggesting this solution to my problem.
Signed-off-by: Per Cederqvist <cederp@opera.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
This one was a bit experimental if I remember correctly, so you may
want to skip it or make the feature optional.
Documentation/guilt.7 | 4 +
guilt | 52 +++++-
guilt-branch | 12 +-
guilt-commit | 7 +
guilt-import-commit | 4 +-
guilt-repair | 7 +-
regression/scaffold | 3 +-
regression/t-052.out | 24 +--
regression/t-052.sh | 7 +-
regression/t-061.out | 468 ++++++++++++++++++++++++++++++++++++++++++++++++++
regression/t-061.sh | 148 ++++++++++++++++
11 files changed, 713 insertions(+), 23 deletions(-)
create mode 100644 regression/t-061.out
create mode 100755 regression/t-061.sh
diff --git a/Documentation/guilt.7 b/Documentation/guilt.7
index 860e6d6..c3fdb3d 100644
--- a/Documentation/guilt.7
+++ b/Documentation/guilt.7
@@ -43,6 +43,10 @@ guards: This file contains any guards that should be applied to the series when
series: This file contains a list of all the patch filenames relative to the per\-branch patch directory\&. Empty and commented out lines are ignored\&.
status: This file contains the state of the stack\&. What patches are applied\&.
+.SH "BRANCH USAGE"
+When you have pushed a patch, Guilt automatically changes to a freshly created Git branch\&. The name of the new branch is formed by prepending \fBguilt/\fR to the name of the original branch\&. This is done so that you do not accidentally push a set of Guilt patches to a remote Git repository\&. Once you pop all patches Guilt automatically changes back to the original branch\&.
+
+This is mostly transparent\&. The only thing you need to remember is that if you use \fBgit checkout\fR to switch to a branch while you have Guilt patches applied, you should use \fBgit checkout guilt/BRANCH\fR instead of \fBgit checkout BRANCH\fR when you want to change back later.
.SH "HOOKS"
Any guilt operation may execute zero or more hook scripts which can be used to run any housekeeping commands or even abort the execution of the command\&.
.SH "HOOKS DIRECTORY"
diff --git a/guilt b/guilt
index 5bcc498..66a671a 100755
--- a/guilt
+++ b/guilt
@@ -408,9 +408,9 @@ head_check()
return 0 ;;
esac
- if [ "`git rev-parse refs/heads/$branch`" != "`git rev-parse $1`" ]; then
+ if [ "`git rev-parse refs/heads/\`git_branch\``" != "`git rev-parse $1`" ]; then
disp "Expected HEAD commit $1" >&2
- disp " got `git rev-parse refs/heads/$branch`" >&2
+ disp " got `git rev-parse refs/heads/\`git_branch\``" >&2
return 1
fi
return 0
@@ -500,6 +500,11 @@ pop_many_patches()
n=`expr $n - $2`
head_n "$n" < "$applied" > "$applied.tmp"
mv "$applied.tmp" "$applied"
+ if [ -z "`get_top 2>/dev/null`" ] && [ "`git symbolic-ref HEAD`" = "refs/heads/$GUILT_PREFIX$branch" ] && ! $old_style_prefix
+ then
+ git symbolic-ref HEAD refs/heads/$branch
+ git update-ref -d refs/heads/$GUILT_PREFIX$branch
+ fi
)
}
@@ -585,7 +590,13 @@ commit()
# commit
treeish=`git write-tree`
commitish=`git commit-tree $treeish -p $2 < "$TMP_MSG"`
- git update-ref HEAD $commitish
+ if $old_style_prefix || git rev-parse --verify --quiet refs/heads/$GUILT_PREFIX$branch >/dev/null
+ then
+ git update-ref HEAD $commitish
+ else
+ git branch $GUILT_PREFIX$branch $commitish
+ git symbolic-ref HEAD refs/heads/$GUILT_PREFIX$branch
+ fi
# mark patch as applied
git update-ref "refs/patches/$branch/$pname" HEAD
@@ -825,6 +836,9 @@ guilt_push_diff_context=1
# default diffstat value: true or false
DIFFSTAT_DEFAULT="false"
+# Prefix for guilt branches.
+GUILT_PREFIX=guilt/
+
#
# Parse any part of .git/config that belongs to us
#
@@ -839,7 +853,28 @@ diffstat=`git config --bool guilt.diffstat`
GUILT_DIR="$GIT_DIR/patches"
-branch=`get_branch`
+# To make it harder to accidentally do "git push" with a guilt patch
+# applied, "guilt push" changes branch from e.g. "master" to
+# "guilt/master". Set $git_branch to the full branch name, and
+# $branch to the abbreviated name that the user sees most of the time.
+# Note: old versions of guilt did not add the "guilt/" prefix. This
+# code handles that case as well. The prefix will be added when you
+# have no patches applied and do a "guilt push".
+raw_git_branch=`get_branch`
+branch=`echo "$raw_git_branch" | sed -e 's,^'$GUILT_PREFIX',,'`
+
+git_branch()
+{
+ if $old_style_prefix
+ then
+ echo $branch
+ elif [ -z "`get_top 2>/dev/null`" ]
+ then
+ echo $branch
+ else
+ echo $GUILT_PREFIX$branch
+ fi
+}
# most of the time we want to verify that the repo's branch has been
# initialized, but every once in a blue moon (e.g., we want to run guilt init),
@@ -876,4 +911,13 @@ else
die "Unsupported operating system: $UNAME_S"
fi
+if [ "$branch" = "$raw_git_branch" ] && [ -n "`get_top 2>/dev/null`" ]
+then
+ # This is for compat with old repositories that still have a
+ # pushed patch without the new-style branch prefix.
+ old_style_prefix=true
+else
+ old_style_prefix=false
+fi
+
_main "$@"
diff --git a/guilt-branch b/guilt-branch
index 909f740..4a1f53e 100755
--- a/guilt-branch
+++ b/guilt-branch
@@ -35,8 +35,16 @@ cat "$applied" | while read n; do
`git rev-parse "refs/patches/$branch/$n"` ""
done
-git branch "$newbranch"
-git checkout "$newbranch"
+if $old_style_prefix || [ -z "`get_top 2>/dev/null`" ]
+then
+ newgitbranch="$newbranch"
+else
+ git update-ref "refs/heads/$newbranch" "refs/heads/$branch" ""
+ newgitbranch="$GUILT_PREFIX$newbranch"
+fi
+
+git branch "$newgitbranch"
+git checkout "$newgitbranch"
mkdir -p "$GUILT_DIR/`dirname $newbranch`"
diff --git a/guilt-commit b/guilt-commit
index 4228be6..e425399 100755
--- a/guilt-commit
+++ b/guilt-commit
@@ -43,4 +43,11 @@ done
sed -n -e "${pat_keep}" "$applied" > "$applied.tmp"
mv "$applied.tmp" "$applied"
+# if we removed the last patch, switch back to the base branch
+if [ `wc -l < "$applied"` -eq 0 ] && [ "`git symbolic-ref HEAD`" = "refs/heads/$GUILT_PREFIX$branch" ] && ! $old_style_prefix
+then
+ git update-ref refs/heads/$branch refs/heads/$GUILT_PREFIX$branch
+ git symbolic-ref HEAD refs/heads/$branch
+ git update-ref -d refs/heads/$GUILT_PREFIX$branch
+fi
}
diff --git a/guilt-import-commit b/guilt-import-commit
index 3045a5f..54c1de0 100755
--- a/guilt-import-commit
+++ b/guilt-import-commit
@@ -23,7 +23,7 @@ if ! must_commit_first; then
fi
disp "About to begin conversion..." >&2
-disp "Current head: `cat $GIT_DIR/refs/heads/$branch`" >&2
+disp "Current head: `cat $GIT_DIR/refs/heads/\`git_branch\``" >&2
for rev in `git rev-list $rhash`; do
s=`git log --pretty=oneline -1 $rev | cut -c 42-`
@@ -68,6 +68,6 @@ for rev in `git rev-list $rhash`; do
done
disp "Done." >&2
-disp "Current head: `cat $GIT_DIR/refs/heads/$branch`" >&2
+disp "Current head: `cat $GIT_DIR/refs/heads/\`git_branch\``" >&2
}
diff --git a/guilt-repair b/guilt-repair
index 77ad223..c0bf3ed 100755
--- a/guilt-repair
+++ b/guilt-repair
@@ -84,6 +84,11 @@ repair_pushed()
# blow away any commits
git reset --hard "$newrev" > /dev/null
+ if [ "`git symbolic-ref HEAD`" = "refs/heads/$GUILT_PREFIX$branch" ] && ! $old_style_prefix
+ then
+ git symbolic-ref HEAD refs/heads/$branch
+ git update-ref -d refs/heads/$GUILT_PREFIX$branch
+ fi
# blow away the applied stack
remove_patch_refs < "$applied"
@@ -112,7 +117,7 @@ case "$1" in
;;
esac
-oldrev=`git show-ref -s "refs/heads/$branch"`
+oldrev=`git show-ref -s "refs/heads/\`git_branch\`"`
case "$repair" in
full)
diff --git a/regression/scaffold b/regression/scaffold
index 9db79a9..546d8c6 100644
--- a/regression/scaffold
+++ b/regression/scaffold
@@ -38,7 +38,8 @@ function replace_path
-e "s,^Usage: guilt-,Usage: guilt ,g" \
-e "s,\.\.\. initial, initial,g" \
-e "s,^Already on\( branch\)\? [\"']\([^\"']*\)[\"']$,Already on \"\2\",g" \
- -e "s,^Switched to branch [\"']\([^\"']*\)[\"'],Switched to branch \"\1\",g"
+ -e "s,^Switched to branch [\"']\([^\"']*\)[\"'],Switched to branch \"\1\",g" \
+ -e "\\,^Deleted branch guilt/.* (was .*).$,d"
}
function filter_dd
diff --git a/regression/t-052.out b/regression/t-052.out
index 3b4a629..8205f35 100644
--- a/regression/t-052.out
+++ b/regression/t-052.out
@@ -47,7 +47,7 @@ f da39a3ee5e6b4b0d3255bfef95601890afd80709 .git/patches/master/status
Applying patch..modify
Patch applied.
% guilt branch br-modify
-Switched to branch "br-modify"
+Switched to branch "guilt/br-modify"
% list_files
d .git/patches
d .git/patches/br-
@@ -76,8 +76,8 @@ f bc9ab2e0f5db99d483961e956e814d963f0309f8 .git/patches/master/modify
f da39a3ee5e6b4b0d3255bfef95601890afd80709 .git/patches/br-/status
r 33633e7a1aa31972f125878baf7807be57b1672d .git/refs/patches/br-modify/modify
r 33633e7a1aa31972f125878baf7807be57b1672d .git/refs/patches/master/modify
-% git checkout master
-Switched to branch "master"
+% git checkout guilt/master
+Switched to branch "guilt/master"
% list_files
d .git/patches
d .git/patches/br-
@@ -109,7 +109,7 @@ r 33633e7a1aa31972f125878baf7807be57b1672d .git/refs/patches/master/modify
Applying patch..add
Patch applied.
% guilt branch br-add
-Switched to branch "br-add"
+Switched to branch "guilt/br-add"
% list_files
d .git/patches
d .git/patches/br-
@@ -149,8 +149,8 @@ r 33633e7a1aa31972f125878baf7807be57b1672d .git/refs/patches/br-modify/modify
r 33633e7a1aa31972f125878baf7807be57b1672d .git/refs/patches/master/modify
r 37d588cc39848368810e88332bd03b083f2ce3ac .git/refs/patches/br-add/add
r 37d588cc39848368810e88332bd03b083f2ce3ac .git/refs/patches/master/add
-% git checkout master
-Switched to branch "master"
+% git checkout guilt/master
+Switched to branch "guilt/master"
% list_files
d .git/patches
d .git/patches/br-
@@ -193,7 +193,7 @@ r 37d588cc39848368810e88332bd03b083f2ce3ac .git/refs/patches/master/add
Applying patch..remove
Patch applied.
% guilt branch br-remove
-Switched to branch "br-remove"
+Switched to branch "guilt/br-remove"
% list_files
d .git/patches
d .git/patches/br-
@@ -245,8 +245,8 @@ r 37d588cc39848368810e88332bd03b083f2ce3ac .git/refs/patches/br-remove/add
r 37d588cc39848368810e88332bd03b083f2ce3ac .git/refs/patches/master/add
r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/br-remove/remove
r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/master/remove
-% git checkout master
-Switched to branch "master"
+% git checkout guilt/master
+Switched to branch "guilt/master"
% list_files
d .git/patches
d .git/patches/br-
@@ -301,7 +301,7 @@ r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/master/remove
Applying patch..mode
Patch applied.
% guilt branch br-mode
-Switched to branch "br-mode"
+Switched to branch "guilt/br-mode"
% list_files
d .git/patches
d .git/patches/br-
@@ -366,5 +366,5 @@ r ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba .git/refs/patches/master/mode
r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/br-mode/remove
r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/br-remove/remove
r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/master/remove
-% git checkout master
-Switched to branch "master"
+% git checkout guilt/master
+Switched to branch "guilt/master"
diff --git a/regression/t-052.sh b/regression/t-052.sh
index e9c1a59..05bc55b 100755
--- a/regression/t-052.sh
+++ b/regression/t-052.sh
@@ -12,5 +12,10 @@ for x in "" modify add remove mode ; do
[ "$x" != "" ] && guilt push "$x"
cmd guilt branch br-$x
cmd list_files
- cmd git checkout master
+ if [ "$x" != "" ]
+ then
+ cmd git checkout guilt/master
+ else
+ cmd git checkout master
+ fi
done
diff --git a/regression/t-061.out b/regression/t-061.out
new file mode 100644
index 0000000..8365236
--- /dev/null
+++ b/regression/t-061.out
@@ -0,0 +1,468 @@
+% setup_repo
+% guilt push -a
+Applying patch..modify
+Patch applied.
+Applying patch..add
+Patch applied.
+Applying patch..remove
+Patch applied.
+Applying patch..mode
+Patch applied.
+% list_files
+d .git/patches
+d .git/patches/master
+d .git/refs/patches
+d .git/refs/patches/master
+f 22930c6d1f1938f298a4fca51c57e4b47171db21 .git/patches/master/mode
+f 413390f3906f16f30b054a4fb86c1e014b964504 .git/patches/master/remove
+f 71596bf71b72c2717e1aee378aabefbfa19ab7c8 .git/patches/master/status
+f 9c18cc7abe6b87f18503714a80a677b4094eb457 .git/patches/master/add
+f bacb4aad8a55fe4e7aa58a9ae169990bb764069f .git/patches/master/series
+f bc9ab2e0f5db99d483961e956e814d963f0309f8 .git/patches/master/modify
+r 33633e7a1aa31972f125878baf7807be57b1672d .git/refs/patches/master/modify
+r 37d588cc39848368810e88332bd03b083f2ce3ac .git/refs/patches/master/add
+r ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba .git/refs/patches/master/mode
+r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/master/remove
+% git for-each-ref
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/heads/guilt/master
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/patches/master/mode
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 commit refs/patches/master/remove
+% git update-ref refs/heads/master refs/heads/guilt/master
+% git symbolic-ref HEAD refs/heads/master
+% git update-ref -d refs/heads/guilt/master
+% git for-each-ref
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/heads/master
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/patches/master/mode
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 commit refs/patches/master/remove
+% list_files
+d .git/patches
+d .git/patches/master
+d .git/refs/patches
+d .git/refs/patches/master
+f 22930c6d1f1938f298a4fca51c57e4b47171db21 .git/patches/master/mode
+f 413390f3906f16f30b054a4fb86c1e014b964504 .git/patches/master/remove
+f 71596bf71b72c2717e1aee378aabefbfa19ab7c8 .git/patches/master/status
+f 9c18cc7abe6b87f18503714a80a677b4094eb457 .git/patches/master/add
+f bacb4aad8a55fe4e7aa58a9ae169990bb764069f .git/patches/master/series
+f bc9ab2e0f5db99d483961e956e814d963f0309f8 .git/patches/master/modify
+r 33633e7a1aa31972f125878baf7807be57b1672d .git/refs/patches/master/modify
+r 37d588cc39848368810e88332bd03b083f2ce3ac .git/refs/patches/master/add
+r ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba .git/refs/patches/master/mode
+r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/master/remove
+% guilt pop
+Now at remove.
+% git for-each-ref
+ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 commit refs/heads/master
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 commit refs/patches/master/remove
+% guilt push
+Applying patch..mode
+Patch applied.
+% git for-each-ref
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/heads/master
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/patches/master/mode
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 commit refs/patches/master/remove
+% guilt pop
+Now at remove.
+% git for-each-ref
+ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 commit refs/heads/master
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 commit refs/patches/master/remove
+% guilt pop
+Now at add.
+% git for-each-ref
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/heads/master
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+% guilt push
+Applying patch..remove
+Patch applied.
+% git for-each-ref
+ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 commit refs/heads/master
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 commit refs/patches/master/remove
+% guilt pop
+Now at add.
+% git for-each-ref
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/heads/master
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+% guilt pop
+Now at modify.
+% git for-each-ref
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/heads/master
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+% guilt push
+Applying patch..add
+Patch applied.
+% git for-each-ref
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/heads/master
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+% guilt pop
+Now at modify.
+% git for-each-ref
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/heads/master
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+% guilt pop
+All patches popped.
+% git for-each-ref
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+% guilt push
+Applying patch..modify
+Patch applied.
+% git for-each-ref
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/heads/guilt/master
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+% guilt pop
+All patches popped.
+% git for-each-ref
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+% guilt pop
+No patches applied.
+% git for-each-ref
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+% guilt push
+Applying patch..modify
+Patch applied.
+% git for-each-ref
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/heads/guilt/master
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+% guilt pop
+All patches popped.
+% git for-each-ref
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+% guilt push -a
+Applying patch..modify
+Patch applied.
+Applying patch..add
+Patch applied.
+Applying patch..remove
+Patch applied.
+Applying patch..mode
+Patch applied.
+% git update-ref refs/heads/master refs/heads/guilt/master
+% git symbolic-ref HEAD refs/heads/master
+% git update-ref -d refs/heads/guilt/master
+% git for-each-ref
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/heads/master
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/patches/master/mode
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 commit refs/patches/master/remove
+% guilt pop -a
+All patches popped.
+% git for-each-ref
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+% guilt push add
+Applying patch..modify
+Patch applied.
+Applying patch..add
+Patch applied.
+% git for-each-ref
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/heads/guilt/master
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+% git update-ref refs/heads/master refs/heads/guilt/master
+% git symbolic-ref HEAD refs/heads/master
+% git update-ref -d refs/heads/guilt/master
+% guilt branch topic
+Switched to branch "topic"
+% git for-each-ref
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/heads/master
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/heads/topic
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/topic/add
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/topic/modify
+% guilt pop -a
+All patches popped.
+% guilt push
+Applying patch..modify
+Patch applied.
+% git for-each-ref
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/heads/guilt/topic
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/heads/master
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/topic
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/topic/modify
+% guilt pop -a
+All patches popped.
+% git checkout master
+Switched to branch "master"
+% guilt pop -a
+All patches popped.
+% git branch -d topic
+Deleted branch topic (was d485041).
+% rm -r .git/patches/topic
+% git for-each-ref
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+% list_files
+d .git/patches
+d .git/patches/master
+d .git/refs/patches
+d .git/refs/patches/master
+d .git/refs/patches/topic
+f 22930c6d1f1938f298a4fca51c57e4b47171db21 .git/patches/master/mode
+f 413390f3906f16f30b054a4fb86c1e014b964504 .git/patches/master/remove
+f 9c18cc7abe6b87f18503714a80a677b4094eb457 .git/patches/master/add
+f bacb4aad8a55fe4e7aa58a9ae169990bb764069f .git/patches/master/series
+f bc9ab2e0f5db99d483961e956e814d963f0309f8 .git/patches/master/modify
+f da39a3ee5e6b4b0d3255bfef95601890afd80709 .git/patches/master/status
+% guilt push -a
+Applying patch..modify
+Patch applied.
+Applying patch..add
+Patch applied.
+Applying patch..remove
+Patch applied.
+Applying patch..mode
+Patch applied.
+% git update-ref refs/heads/master refs/heads/guilt/master
+% git symbolic-ref HEAD refs/heads/master
+% git update-ref -d refs/heads/guilt/master
+% guilt branch topic
+Switched to branch "topic"
+% git for-each-ref
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/heads/master
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/heads/topic
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/patches/master/mode
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 commit refs/patches/master/remove
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/topic/add
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/patches/topic/mode
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/topic/modify
+ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 commit refs/patches/topic/remove
+% guilt pop -a
+All patches popped.
+% git checkout master
+Switched to branch "master"
+% guilt pop -a
+All patches popped.
+% git branch -d topic
+Deleted branch topic (was d485041).
+% rm -r .git/patches/topic
+% git for-each-ref
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+% list_files
+d .git/patches
+d .git/patches/master
+d .git/refs/patches
+d .git/refs/patches/master
+d .git/refs/patches/topic
+f 22930c6d1f1938f298a4fca51c57e4b47171db21 .git/patches/master/mode
+f 413390f3906f16f30b054a4fb86c1e014b964504 .git/patches/master/remove
+f 9c18cc7abe6b87f18503714a80a677b4094eb457 .git/patches/master/add
+f bacb4aad8a55fe4e7aa58a9ae169990bb764069f .git/patches/master/series
+f bc9ab2e0f5db99d483961e956e814d963f0309f8 .git/patches/master/modify
+f da39a3ee5e6b4b0d3255bfef95601890afd80709 .git/patches/master/status
+% guilt branch topic
+Switched to branch "topic"
+% git for-each-ref
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/topic
+% list_files
+d .git/patches
+d .git/patches/master
+d .git/patches/topic
+d .git/refs/patches
+d .git/refs/patches/master
+d .git/refs/patches/topic
+f 22930c6d1f1938f298a4fca51c57e4b47171db21 .git/patches/master/mode
+f 22930c6d1f1938f298a4fca51c57e4b47171db21 .git/patches/topic/mode
+f 413390f3906f16f30b054a4fb86c1e014b964504 .git/patches/master/remove
+f 413390f3906f16f30b054a4fb86c1e014b964504 .git/patches/topic/remove
+f 9c18cc7abe6b87f18503714a80a677b4094eb457 .git/patches/master/add
+f 9c18cc7abe6b87f18503714a80a677b4094eb457 .git/patches/topic/add
+f bacb4aad8a55fe4e7aa58a9ae169990bb764069f .git/patches/master/series
+f bacb4aad8a55fe4e7aa58a9ae169990bb764069f .git/patches/topic/series
+f bc9ab2e0f5db99d483961e956e814d963f0309f8 .git/patches/master/modify
+f bc9ab2e0f5db99d483961e956e814d963f0309f8 .git/patches/topic/modify
+f da39a3ee5e6b4b0d3255bfef95601890afd80709 .git/patches/master/status
+f da39a3ee5e6b4b0d3255bfef95601890afd80709 .git/patches/topic/status
+% guilt pop -a
+No patches applied.
+% git checkout master
+Switched to branch "master"
+% guilt pop -a
+No patches applied.
+% git branch -d topic
+Deleted branch topic (was d485041).
+% rm -r .git/patches/topic
+% git for-each-ref
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+% list_files
+d .git/patches
+d .git/patches/master
+d .git/refs/patches
+d .git/refs/patches/master
+d .git/refs/patches/topic
+f 22930c6d1f1938f298a4fca51c57e4b47171db21 .git/patches/master/mode
+f 413390f3906f16f30b054a4fb86c1e014b964504 .git/patches/master/remove
+f 9c18cc7abe6b87f18503714a80a677b4094eb457 .git/patches/master/add
+f bacb4aad8a55fe4e7aa58a9ae169990bb764069f .git/patches/master/series
+f bc9ab2e0f5db99d483961e956e814d963f0309f8 .git/patches/master/modify
+f da39a3ee5e6b4b0d3255bfef95601890afd80709 .git/patches/master/status
+% guilt push -a
+Applying patch..modify
+Patch applied.
+Applying patch..add
+Patch applied.
+Applying patch..remove
+Patch applied.
+Applying patch..mode
+Patch applied.
+% guilt branch topic
+Switched to branch "guilt/topic"
+% git for-each-ref
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/heads/guilt/master
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/heads/guilt/topic
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/topic
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/patches/master/mode
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 commit refs/patches/master/remove
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/topic/add
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/patches/topic/mode
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/topic/modify
+ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 commit refs/patches/topic/remove
+% list_files
+d .git/patches
+d .git/patches/master
+d .git/patches/topic
+d .git/refs/patches
+d .git/refs/patches/master
+d .git/refs/patches/topic
+f 22930c6d1f1938f298a4fca51c57e4b47171db21 .git/patches/master/mode
+f 22930c6d1f1938f298a4fca51c57e4b47171db21 .git/patches/topic/mode
+f 413390f3906f16f30b054a4fb86c1e014b964504 .git/patches/master/remove
+f 413390f3906f16f30b054a4fb86c1e014b964504 .git/patches/topic/remove
+f 71596bf71b72c2717e1aee378aabefbfa19ab7c8 .git/patches/master/status
+f 71596bf71b72c2717e1aee378aabefbfa19ab7c8 .git/patches/topic/status
+f 9c18cc7abe6b87f18503714a80a677b4094eb457 .git/patches/master/add
+f 9c18cc7abe6b87f18503714a80a677b4094eb457 .git/patches/topic/add
+f bacb4aad8a55fe4e7aa58a9ae169990bb764069f .git/patches/master/series
+f bacb4aad8a55fe4e7aa58a9ae169990bb764069f .git/patches/topic/series
+f bc9ab2e0f5db99d483961e956e814d963f0309f8 .git/patches/master/modify
+f bc9ab2e0f5db99d483961e956e814d963f0309f8 .git/patches/topic/modify
+r 33633e7a1aa31972f125878baf7807be57b1672d .git/refs/patches/master/modify
+r 33633e7a1aa31972f125878baf7807be57b1672d .git/refs/patches/topic/modify
+r 37d588cc39848368810e88332bd03b083f2ce3ac .git/refs/patches/master/add
+r 37d588cc39848368810e88332bd03b083f2ce3ac .git/refs/patches/topic/add
+r ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba .git/refs/patches/master/mode
+r ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba .git/refs/patches/topic/mode
+r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/master/remove
+r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/topic/remove
+% guilt pop -a
+All patches popped.
+% git for-each-ref
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/heads/guilt/master
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/topic
+37d588cc39848368810e88332bd03b083f2ce3ac commit refs/patches/master/add
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba commit refs/patches/master/mode
+33633e7a1aa31972f125878baf7807be57b1672d commit refs/patches/master/modify
+ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 commit refs/patches/master/remove
+% guilt pop -a
+No patches applied.
+ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba
+% git checkout guilt/master
+Switched to branch "guilt/master"
+% guilt pop -a
+All patches popped.
+% git branch -d topic
+Deleted branch topic (was d485041).
+% rm -r .git/patches/topic
+% git for-each-ref
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+% list_files
+d .git/patches
+d .git/patches/master
+d .git/refs/patches
+d .git/refs/patches/master
+d .git/refs/patches/topic
+f 22930c6d1f1938f298a4fca51c57e4b47171db21 .git/patches/master/mode
+f 413390f3906f16f30b054a4fb86c1e014b964504 .git/patches/master/remove
+f 9c18cc7abe6b87f18503714a80a677b4094eb457 .git/patches/master/add
+f bacb4aad8a55fe4e7aa58a9ae169990bb764069f .git/patches/master/series
+f bc9ab2e0f5db99d483961e956e814d963f0309f8 .git/patches/master/modify
+f da39a3ee5e6b4b0d3255bfef95601890afd80709 .git/patches/master/status
+% guilt new newpatch
+% git for-each-ref --format=%(refname)
+refs/heads/guilt/master
+refs/heads/master
+refs/patches/master/newpatch
+% guilt pop
+All patches popped.
+% guilt push
+Applying patch..newpatch
+Patch applied.
+% git for-each-ref
+25465dc1687f3833ecbd4e8bca437e522d7026db commit refs/heads/guilt/master
+d4850419ccc1146c7169f500725ce504b9774ed0 commit refs/heads/master
+25465dc1687f3833ecbd4e8bca437e522d7026db commit refs/patches/master/newpatch
+% git branch
+* guilt/master
+ master
+% guilt applied
+newpatch
+% guilt commit -a
+% git for-each-ref
+25465dc1687f3833ecbd4e8bca437e522d7026db commit refs/heads/master
+% git branch
+* master
+% guilt push -a
+Applying patch..modify
+Patch applied.
+Applying patch..add
+Patch applied.
+Applying patch..remove
+Patch applied.
+Applying patch..mode
+Patch applied.
+% guilt applied
+modify
+add
+remove
+mode
+% git branch
+* guilt/master
+ master
+% git for-each-ref
+fefbdcef61022d473838926619f31e030dd04fdc commit refs/heads/guilt/master
+25465dc1687f3833ecbd4e8bca437e522d7026db commit refs/heads/master
+5effcbeb303e8433935151d8c69f3bf63db1e8ef commit refs/patches/master/add
+fefbdcef61022d473838926619f31e030dd04fdc commit refs/patches/master/mode
+9509f22e2e627756d87b42432931c45955b74234 commit refs/patches/master/modify
+9cbe2fc643b1a9e2179a8738f80424a1c2aa202d commit refs/patches/master/remove
+% guilt commit -n 2
+% git for-each-ref
+fefbdcef61022d473838926619f31e030dd04fdc commit refs/heads/guilt/master
+25465dc1687f3833ecbd4e8bca437e522d7026db commit refs/heads/master
+fefbdcef61022d473838926619f31e030dd04fdc commit refs/patches/master/mode
+9cbe2fc643b1a9e2179a8738f80424a1c2aa202d commit refs/patches/master/remove
+% git branch
+* guilt/master
+ master
+% guilt commit -n 2
+% git for-each-ref
+fefbdcef61022d473838926619f31e030dd04fdc commit refs/heads/master
+% git branch
+* master
+% guilt series
diff --git a/regression/t-061.sh b/regression/t-061.sh
new file mode 100755
index 0000000..1411baa
--- /dev/null
+++ b/regression/t-061.sh
@@ -0,0 +1,148 @@
+#!/bin/bash
+#
+# Test the branch-switching upgrade code
+#
+
+source $REG_DIR/scaffold
+
+old_style_branch() {
+ # Modify the refs so that it looks as if the patch series was applied
+ # by an old version of guilt.
+ cmd git update-ref refs/heads/$1 refs/heads/guilt/$1
+ cmd git symbolic-ref HEAD refs/heads/$1
+ cmd git update-ref -d refs/heads/guilt/$1
+}
+
+remove_topic() {
+ cmd guilt pop -a
+ if git rev-parse --verify --quiet guilt/master
+ then
+ cmd git checkout guilt/master
+ else
+ cmd git checkout master
+ fi
+ cmd guilt pop -a
+ cmd git branch -d $1
+ cmd rm -r .git/patches/$1
+ cmd git for-each-ref
+ cmd list_files
+}
+
+function fixup_time_info
+{
+ touch -a -m -t "$TOUCH_DATE" ".git/patches/master/$1"
+}
+
+cmd setup_repo
+
+cmd guilt push -a
+cmd list_files
+cmd git for-each-ref
+
+# Pop and push patches. Check that the repo is converted to new-style
+# refs when no patches are applied and a patch is pushed.
+old_style_branch master
+cmd git for-each-ref
+
+cmd list_files
+
+for i in `seq 5`
+do
+ cmd guilt pop
+ cmd git for-each-ref
+ cmd guilt push
+ cmd git for-each-ref
+ cmd guilt pop
+ cmd git for-each-ref
+done
+
+# Check that "pop -a" does the right thing.
+cmd guilt push -a
+
+old_style_branch master
+
+cmd git for-each-ref
+
+cmd guilt pop -a
+
+cmd git for-each-ref
+
+# Check that pushing two patches converts the repo to now-style (since
+# it currently has no patches applied).
+cmd guilt push add
+cmd git for-each-ref
+
+# Check guilt branch with a few patches applied.
+old_style_branch master
+cmd guilt branch topic
+cmd git for-each-ref
+
+# Check that the topic branch is converted to new-style.
+cmd guilt pop -a
+cmd guilt push
+cmd git for-each-ref
+
+remove_topic topic
+
+# Check guilt branch with the full patch series applied.
+cmd guilt push -a
+old_style_branch master
+cmd guilt branch topic
+cmd git for-each-ref
+
+remove_topic topic
+
+# Check guilt branch with no patches applied.
+# This gives us a new-style checkout.
+cmd guilt branch topic
+cmd git for-each-ref
+cmd list_files
+
+remove_topic topic
+
+# Check guilt branch in a new-style directory with all patches
+# applied. (Strictly speaking, this test should probably move to a
+# file devoted to testing "guilt branch".)
+cmd guilt push -a
+cmd guilt branch topic
+cmd git for-each-ref
+cmd list_files
+cmd guilt pop -a
+cmd git for-each-ref
+
+remove_topic topic
+
+# Check that "guilt new" does the right thing when no patches are
+# applied. (Strictly speaking, this test should maybe move to
+# t-025.sh).
+
+cmd guilt new newpatch
+cmd git for-each-ref '--format=%(refname)'
+cmd guilt pop
+fixup_time_info newpatch
+cmd guilt push
+cmd git for-each-ref
+
+# Check that "guilt commit" does the right thing when committing all
+# applied patches. (Strictly speaking, this test should maybe move to
+# t-030.sh).
+cmd git branch
+cmd guilt applied
+cmd guilt commit -a
+cmd git for-each-ref
+cmd git branch
+
+# Check that "guilt commit" does the right thing when committing only
+# a few of the applied patches. (Strictly speaking, this test should
+# maybe move to t-030.sh).
+cmd guilt push -a
+cmd guilt applied
+cmd git branch
+cmd git for-each-ref
+cmd guilt commit -n 2
+cmd git for-each-ref
+cmd git branch
+cmd guilt commit -n 2
+cmd git for-each-ref
+cmd git branch
+cmd guilt series
--
1.8.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox