Add git-rewrite-commits v2
Subsystems (2)
cover Add git-rewrite-commits v2
From: Sven Verdoolaege <[email protected]>
[PATCH 1/6] revision: allow selection of commits that do not match a pattern [PATCH 2/6] export get_short_sha1
[PATCH 3/6] Define ishex(x) in git-compat-util.h
[PATCH 4/6] refs.c: lock cached_refs during for_each_ref
[PATCH 5/6] revision: mark commits that didn't match a pattern for later use [PATCH 6/6] Add git-rewrite-commits
The first is fairly independent, but it is used in the tests of the last patch and may be replaced by Johannes' extended patch. The next three should be fairly uncontroversial.
The fifth may be considered a waste of a precious bit.
If so, any suggestions for other ways of passing on this information are welcomed.
The sixth contains the actual git-rewrite-commits builtin. My main motivation was that cg-admin-rewritehist doesn't change the SHA1's in commit message and I don't like shell programming.
The main difference with the previous series is that the options are now called --index-filter and --commit-filter instead of --index-map and --commit-map.
The commit filter should now produce a list of commit SHA1 instead of the modified raw commit.
The refs are now rewritten at the very end, which should be safer if anything goes wrong along the way and obviates the need for the call to add_ref_decoration of the previous series.
Most of the changes were requested by Johannes Schindelin. I'm sure he'll let me know if I forgot anything.
In a follow-up patch (series), he will add more helper functions for the filters.
skimo
PATCH 1/6 revision: allow selection of commits that do not match a pattern
From: Sven Verdoolaege <[email protected]>
We do this by maintaining two lists of patterns, one for those that should match and one for those that should not match.
A negative pattern is specified by putting a '!' in front. For example, to show the commits of Jakub Narebski that are not about gitweb, you'd do a
git log --author='Narebski' --grep='!gitweb' --all-match
As an added bonus, this patch also documents --all-match.
--- Documentation/git-rev-list.txt | 17 ++++++++++ revision.c | 64 +++++++++++++++++++++++++++++++++------ revision.h | 1 + 3 files changed, 72 insertions(+), 10 deletions(-)
Documentation/git-rev-list.txt +17 -0
@@ -214,11 +214,19 @@ limiting may be applied. Limit the commits output to ones with author/committer header lines that match the specified pattern (regular expression). + A pattern starting with a '!' will show only commits that do + not match the remainder of the pattern. + To match lines starting with '!', escape the initial '!' + with a backslash. --grep='pattern':: Limit the commits output to ones with log message that matches the specified pattern (regular expression). + A pattern starting with a '!' will show only commits that do + not match the remainder of the pattern. + To match lines starting with '!', escape the initial '!' + with a backslash. --regexp-ignore-case::
@@ -229,6 +237,15 @@ limiting may be applied. Consider the limiting patterns to be extended regular expressions instead of the default basic regular expressions. +--all-match:: + + Without this option, a commit is shown if any of the + (positive or negative) patterns matches, i.e., there + is at least one positive match or not all of the negative + patterns match. With this options, a commit is only + shown if all of the patterns match, i.e., all positive + patterns match and no negative pattern matches. + --remove-empty:: Stop when a given path disappears from the tree.
revision.c +54 -10
111 lines not on this page · raw message
revision.h +1 -0
@@ -84,6 +84,7 @@ struct rev_info {/* Filter by commit log message */ struct grep_opt *grep_filter; +struct grep_opt *grep_neg_filter;/* special limits */ int skip_count;
Signature · 1 line
1.5.3.rc0.100.ge60b4
PATCH 2/6 export get_short_sha1
In reply to [email protected]From: Sven Verdoolaege <[email protected]>
Sometimes it is useful to check whether a given string is exactly a short SHA1.
--- cache.h | 1 + sha1_name.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-)
cache.h +1 -0
@@ -391,6 +391,7 @@ static inline unsigned int hexval(unsigned char c)extern int get_sha1 (const char *str,unsigned char *sha1);extern int get_sha1_with_mode (const char *str,unsigned char *sha1,unsigned *mode); +extern int get_short_sha1 (const char *name,int len,unsigned char *sha1,int quietly);extern int get_sha1_hex (const char *hex,unsigned char *sha1);extern char *sha1_to_hex (const unsigned char *sha1);/* static buffer result! */ extern int read_ref (const char *filename,unsigned char *sha1);
sha1_name.c +1 -2
@@ -154,8 +154,7 @@ static int find_unique_short_object(int len, char *canonical,return 0 ; } -static int get_short_sha1 (const char *name,int len,unsigned char *sha1, -int quietly) +int get_short_sha1 (const char *name,int len,unsigned char *sha1,int quietly) {int i, status;char canonical[40 ];
Signature · 1 line
1.5.3.rc0.100.ge60b4
PATCH 3/6 Define ishex(x) in git-compat-util.h
In reply to [email protected]From: Sven Verdoolaege <[email protected]>
--- builtin-name-rev.c | 1 - ctype.c | 5 +++-- git-compat-util.h | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-)
builtin-name-rev.c +0 -1
@@ -233,7 +233,6 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)break ;for (p_start = p; *p; p++) { -#define ishex (x) (isdigit((x)) || ((x) >= 'a' && (x) <= 'f'))if (!ishex (*p)) forty =0 ; else if (++forty == 40 &&
ctype.c +3 -2
@@ -6,7 +6,8 @@#include "cache.h" #define SS GIT_SPACE -#define AA GIT_ALPHA +#define HA GIT_HEXAL +#define AA GIT_OTHAL#define DD GIT_DIGITunsigned char sane_ctype[256 ] = {
@@ -16,7 +17,7 @@ unsigned char sane_ctype[256] = {DD ,DD ,DD ,DD ,DD ,DD ,DD ,DD ,DD ,DD ,0 ,0 ,0 ,0 ,0 ,0 ,/* 48-15 */ 0 ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,/* 64-15 */ AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,0 ,0 ,0 ,0 ,0 ,/* 80-15 */ -0 ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,/* 96-15 */ +0 ,HA ,HA ,HA ,HA ,HA ,HA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,AA ,/* 96-15 */ AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, 0, 0, 0, 0, 0, /* 112-15 */ /* Nothing in the 128.. range */ };
git-compat-util.h +4 -1
@@ -325,12 +325,15 @@ static inline int has_extension(const char *filename, const char *ext)extern unsigned char sane_ctype[256 ];#define GIT_SPACE 0x01#define GIT_DIGIT 0x02 -#define GIT_ALPHA 0x04 +#define GIT_HEXAL 0x04 +#define GIT_OTHAL 0x08 +#define GIT_ALPHA (GIT_HEXAL | GIT_OTHAL)#define sane_istest (x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)#define isspace (x) sane_istest(x,GIT_SPACE)#define isdigit (x) sane_istest(x,GIT_DIGIT)#define isalpha (x) sane_istest(x,GIT_ALPHA)#define isalnum (x) sane_istest(x,GIT_ALPHA | GIT_DIGIT) +#define ishex (x) sane_istest(x,GIT_HEXAL | GIT_DIGIT)#define tolower (x) sane_case((unsigned char)(x), 0x20)#define toupper (x) sane_case((unsigned char)(x), 0)
Signature · 1 line
1.5.3.rc0.100.ge60b4
Re: [PATCH 3/6] Define ishex(x) in git-compat-util.h
Hi,
git-compat-util.h static inline int has_extension(const char *filename, const char *ext) · line 330
Quoted 12 lines · On Thu, 12 Jul 2007, [email protected] wrote:
git-compat-util.h +3
-1@@ -325,12 +325,15 @@ static inline int has_extension(const char *filename, const char *ext)extern unsigned char sane_ctype[256 ];#define GIT_SPACE 0x01#define GIT_DIGIT 0x02 -#define GIT_ALPHA 0x04 +#define GIT_HEXAL 0x04 +#define GIT_OTHAL 0x08 +#define GIT_ALPHA (GIT_HEXAL | GIT_OTHAL)
I'd have left GIT_ALPHA, and added GIT_HEXDIGIT.
git-compat-util.h static inline int has_extension(const char *filename, const char *ext) · line 336
Quoted 6 lines
git-compat-util.h +1
-0#define sane_istest (x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)#define isspace (x) sane_istest(x,GIT_SPACE)#define isdigit (x) sane_istest(x,GIT_DIGIT)#define isalpha (x) sane_istest(x,GIT_ALPHA)#define isalnum (x) sane_istest(x,GIT_ALPHA | GIT_DIGIT) +#define ishex (x) sane_istest(x,GIT_HEXAL | GIT_DIGIT)
I know, I originally proposed this. In the mean time, however, I found that this gem should be even better (in terms of diff size):
#define ishex(x) (hexval(x) >= 0)
Ciao,
Dscho
PATCH 4/6 refs.c: lock cached_refs during for_each_ref
In reply to [email protected]From: Sven Verdoolaege <[email protected]>
If the function called by for_each_ref modifies a ref in any way, the cached_refs that for_each_ref was looping over would be removed, resulting in undefined behavior.
This patch prevents the cached_refs from being removed while for_each_ref is still iterating over them.
--- refs.c | 37 +++++++++++++++++++++++++++++++++---- 1 files changed, 33 insertions(+), 4 deletions(-)
refs.c +33 -4
@@ -153,6 +153,8 @@ static struct ref_list *sort_ref_list(struct ref_list *list)static struct cached_refs {char did_loose;char did_packed; +char is_locked; +char is_invalidated;struct ref_list *loose;struct ref_list *packed; } cached_refs;
@@ -170,6 +172,11 @@ static void invalidate_cached_refs(void) {struct cached_refs *ca = &cached_refs; +if (ca->is_locked) { + ca->is_invalidated =1 ; +return ; + } +if (ca->did_loose && ca->loose)free_ref_list (ca->loose);if (ca->did_packed && ca->packed)
@@ -178,6 +185,24 @@ static void invalidate_cached_refs(void) ca->did_loose = ca->did_packed =0 ; } +static void lock_cached_refs (void ) +{ +struct cached_refs *ca = &cached_refs; + + ca->is_locked =1 ; +} + +static void unlock_cached_refs (void ) +{ +struct cached_refs *ca = &cached_refs; + + ca->is_locked =0 ; +if (ca->is_invalidated) { +invalidate_cached_refs (); + ca->is_invalidated =0 ; + } +} +static void read_packed_refs (FILE *f,struct cached_refs *cached_refs) {struct ref_list *list =NULL ;
@@ -518,10 +543,12 @@ int peel_ref(const char *ref, unsigned char *sha1)static int do_for_each_ref (const char *base,each_ref_fn fn,int trim,void *cb_data) { -int retval; +int retval =0 ;struct ref_list *packed =get_packed_refs ();struct ref_list *loose =get_loose_refs (); +lock_cached_refs (); +while (packed && loose) {struct ref_list *entry;int cmp =strcmp (packed->name, loose->name);
@@ -538,15 +565,17 @@ static int do_for_each_ref(const char *base, each_ref_fn fn, int trim, } retval =do_one_ref (base, fn, trim, cb_data, entry);if (retval) -return retval; + goto out; }for (packed = packed ? packed : loose; packed; packed = packed->next) { retval =do_one_ref (base, fn, trim, cb_data, packed);if (retval) -return retval; + goto out; } -return 0 ; + out: +unlock_cached_refs (); +return retval; }int head_ref (each_ref_fn fn,void *cb_data)
Signature · 1 line
1.5.3.rc0.100.ge60b4
PATCH 5/6 revision: mark commits that didn't match a pattern for later use
In reply to [email protected]From: Sven Verdoolaege <[email protected]>
--- revision.c | 4 +++- revision.h | 1 + 2 files changed, 4 insertions(+), 1 deletions(-)
revision.c +3 -1
@@ -1446,8 +1446,10 @@ static struct commit *get_revision_1(struct rev_info *revs)if (revs->no_merges && commit->parents && commit->parents->next)continue ; -if (!commit_match (commit, revs)) +if (!commit_match (commit, revs)) { + commit->object.flags |=PRUNED ;continue ; + }if (revs->prune_fn && revs->dense) {/* Commit without changes? */ if (!(commit->object.flags &TREECHANGE )) {
revision.h +1 -0
@@ -10,6 +10,7 @@#define CHILD_SHOWN (1u<<6)#define ADDED (1u<<7)/* Parents already parsed and added? */ #define SYMMETRIC_LEFT (1u<<8) +#define PRUNED (1u<<9)struct rev_info ;struct log_info ;
Signature · 1 line
1.5.3.rc0.100.ge60b4
PATCH 6/6 Add git-rewrite-commits
In reply to [email protected]From: Sven Verdoolaege <[email protected]>
This builtin is similar to git-filter-branch (and cg-admin-rewritehist). The main difference is that git-rewrite-commits will automatically rewrite any SHA1 in a commit message to the rewritten SHA1 as well as any reference (in .git/refs/) that points to a rewritten commit.
It's also a lot faster than git-filter-branch if no external command is called. For example, running either to eliminating a commit specified as a graft results in the following timings, both being performed on a freshly cloned copy of a small repo:
bash-3.00$ time git-filter-branch test Rewrite 274fe3dfb8e8c7d0a6ce05138bdb650de7b459ea (425/425) Rewritten history saved to the test branch real 0m30.845s user 0m13.400s sys 0m19.640s bash-3.00$ time git-rewrite-commits real 0m0.223s user 0m0.080s sys 0m0.140s
The command line is more reminiscent of git-log.
For example you can say
git-rewrite-commits --all
to incorporate grafts in all branches, or
git rewrite-commits --author='!Darl McBribe' --all
to remove all commits by Darl McBribe.
--- .gitignore | 1 + Documentation/cmd-list.perl | 1 + Documentation/git-rewrite-commits.txt | 156 +++++++ Makefile | 1 + builtin-rewrite-commits.c | 712 +++++++++++++++++++++++++++++++++ builtin.h | 1 + git.c | 1 + t/t7005-rewrite-commits.sh | 109 +++++ 8 files changed, 982 insertions(+), 0 deletions(-) create mode 100644 Documentation/git-rewrite-commits.txt create mode 100644 builtin-rewrite-commits.c create mode 100755 t/t7005-rewrite-commits.sh
.gitignore +1 -0
@@ -109,6 +109,7 @@ git-reset git-rev-list git-rev-parse git-revert +git-rewrite-commits git-rm git-runstatus git-send-email
Documentation/cmd-list.perl +1 -0
@@ -166,6 +166,7 @@ git-reset mainporcelain git-revert mainporcelain git-rev-list plumbinginterrogators git-rev-parse ancillaryinterrogators +git-rewrite-commits mainporcelain git-rm mainporcelain git-runstatus ancillaryinterrogators git-send-email foreignscminterface
Documentation/git-rewrite-commits.txt new file +156 -0
156 lines not on this page · raw message
Makefile +1 -0
@@ -370,6 +370,7 @@ BUILTIN_OBJS = \ builtin-rev-list.o \ builtin-rev-parse.o \ builtin-revert.o \ + builtin-rewrite-commits.o \ builtin-rm.o \ builtin-runstatus.o \ builtin-shortlog.o \
builtin-rewrite-commits.c new file +712 -0
712 lines not on this page · raw message
builtin.h +1 -0
@@ -63,6 +63,7 @@ extern int cmd_rerere(int argc, const char **argv, const char *prefix);extern int cmd_rev_list (int argc,const char **argv,const char *prefix);extern int cmd_rev_parse (int argc,const char **argv,const char *prefix);extern int cmd_revert (int argc,const char **argv,const char *prefix); +extern int cmd_rewrite_commits (int argc,const char **argv,const char *prefix);extern int cmd_rm (int argc,const char **argv,const char *prefix);extern int cmd_runstatus (int argc,const char **argv,const char *prefix);extern int cmd_shortlog (int argc,const char **argv,const char *prefix);
git.c +1 -0
@@ -356,6 +356,7 @@ static void handle_internal_command(int argc, const char **argv) { "rev-list", cmd_rev_list, RUN_SETUP }, { "rev-parse", cmd_rev_parse, RUN_SETUP }, { "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE }, + { "rewrite-commits", cmd_rewrite_commits, RUN_SETUP }, { "rm", cmd_rm, RUN_SETUP | NEED_WORK_TREE }, { "runstatus", cmd_runstatus, RUN_SETUP | NEED_WORK_TREE }, { "shortlog", cmd_shortlog, RUN_SETUP | USE_PAGER },
t/t7005-rewrite-commits.sh new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
1.5.3.rc0.100.ge60b4
Re: [PATCH 6/6] Add git-rewrite-commits
Quoted 4 lines · On Thu, Jul 12, 2007 at 09:06:03PM +0200, [email protected] wrote:
(quoted diff) +4
-0+static int rewrite_parents(struct commit *commit, int path_pruning) +{ + int n; + struct commit_list *list, *parents, **prev;
Review
Quoted 10 lines
(quoted diff) +10
-0+ unsigned char sha1[20]; + + for (n = 0, prev = &commit->parents; *prev; ++n) { + list = *prev; + + rewrite_parents(list->item, path_pruning); + if (!is_pruned(list->item, path_pruning)) { + prev = &list->next; + continue; + }
Oops... that should be the other way around...
builtin-rewrite-commits.c +1 -1
@@ -279,11 +279,11 @@ static int rewrite_parents(struct commit *commit, int path_pruning)for (n =0 , prev = &commit->parents; *prev; ++n) { list = *prev; -rewrite_parents (list->item, path_pruning);if (!is_pruned (list->item, path_pruning)) { prev = &list->next;continue ; } +rewrite_parents (list->item, path_pruning);hashcpy (sha1, list->item->object.sha1);get_rewritten_sha1 (sha1);
I'll include it in my next version.
skimo
Re: [PATCH 6/6] Add git-rewrite-commits
In reply to [email protected]Hi,
Documentation/git-rewrite-commits.txt line 11
Quoted 4 lines · On Thu, 12 Jul 2007, [email protected] wrote:
Documentation/git-rewrite-commits.txt new file +4
-0+SYNOPSIS +-------- +'git-rewrite-commits' [--index-filter <command>] [--commit-filter <command>] + [<rev-list options>...]
--write-sha1-mappings is missing.
Documentation/git-rewrite-commits.txt line 46
Quoted 7 lines
Documentation/git-rewrite-commits.txt new file +7
-0+Filters +~~~~~~~ + +The filters are applied in the order as listed below. The <command> +argument is run as "sh -c '<command'>", with the $GIT_COMMIT +environment variable set to the commit that is being rewritten. +If any call to a filter fails, then git-rewrite-commits will abort.
Here you should note that a couple of helper functions are defined for ease of use.
Documentation/git-rewrite-commits.txt line 71
Quoted 2 lines
+--write-sha1-mapping
Documentation/git-rewrite-commits.txt new file +1
-0+ Write mapping of old SHA1s to new SHA1s for use in filters.
Where? How to use it?
Review
Quoted 3 lines
+<rev-list-options>::
(quoted diff) +2
-0+ Selects the commits to be rewritten, defaulting to the history + that lead to HEAD.
s/the history that lead to HEAD/the current branch/
Documentation/git-rewrite-commits.txt line 87
Quoted 8 lines
Documentation/git-rewrite-commits.txt new file +8
-0+Examples +-------- + +Suppose you want to remove a file (containing confidential information +or copyright violation) from all commits: + +---------------------------------------------------------------------------- +git rewrite-commits --index-filter 'git update-index --remove filename || :'
We seem to prefer "$ git" instead of just "git" in the other man pages' examples.
Documentation/git-rewrite-commits.txt line 91
Quoted 4 lines
+----------------------------------------------------------------------------
Documentation/git-rewrite-commits.txt new file +3
-0+ +Now, you will get the rewritten history saved in your current branch +(the old branch is saved in refs/original).
The "|| :" construct
+ prevents the filter to fail when the given file was not present in the
+ index.
Documentation/git-rewrite-commits.txt line 142
Quoted 9 lines
Documentation/git-rewrite-commits.txt new file +9
-0+To move the whole tree into a subdirectory, or remove it from there: + +--------------------------------------------------------------- +git rewrite-commits --index-filter \ + 'git ls-files -s | sed "s-\t-&newsubdir/-" | + GIT_INDEX_FILE=$GIT_INDEX_FILE.new \ + git update-index --index-info && + mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' +---------------------------------------------------------------
I imagine that this should be replaced (later! in a different patch!) by either --subdir-filter, or by a shell helper function.
Quoted 1 line
+#include "
grep.h"
I did not compile test, but do you really need that?
builtin-rewrite-commits.c line 24
Quoted 7 lines
builtin-rewrite-commits.c new file +6
-0+struct decoration rewrite_decoration = {"rewritten as" }; + +struct rewrite_decoration { +struct rewrite_decoration *next; +unsigned char sha1[20 ]; +};
I wonder why you give the instance of a "struct decoration" the same name as that of a _different_ struct. IOW it is confusing that there is a "struct rewrite_decoration", but the variable "rewrite_decoration" is no instance of that struct.
Quoted 1 line
+static void
add_rewrite_decoration(struct object *obj, unsigned char *sha1)
Why "struct object *"? You only rewrite commits. Which makes me suspect that your "struct rewrite_decoration" should be a "struct commit_list" to begin with.
Quoted 1 line
+static char *add_parents(char *dest, struct
commit_list*parents)
Since one commit can be rewritten to multiple commits now, you do not know how much space you need to add the parents. Thus you should take a buf_p and a space_p, and use ALLOC_GROW() to grow the buffer as needed.
Quoted 1 line
+static int
skip_one_line(char **buf_p, unsigned long *len_p)
Better rename get_one_line to get_line_length and export it, avoiding code duplication. I have an upcoming patch series adding commit notes, which has that patch.
Besides, you do not _skip_ that line. You use the line, but advance *buf_p before doing so.
Quoted 1 line
+static char *filter_index(char
*orig_hex, struct commit *commit)
const char *, in both cases. You do not plan to modify orig_hex, and you return a sha1_to_hex() buffer, which you also do not plan to modify.
builtin-rewrite-commits.c line 85
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+{ +int argc; +const char *argv[10 ]; +static char index_env[16 +PATH_MAX ];
Style: "16 + PATH_MAX". That happens elsewhere, too.
builtin-rewrite-commits.c line 201
Quoted 11 lines
builtin-rewrite-commits.c new file +11
-0+/* Replace any (short) sha1 of a rewritten commit by the new (short) sha1 */ +static char *rewrite_body (char *dest,unsigned long len,char *buf) +{ +unsigned char sha1[20 ]; + +while (len) { +size_t ll =non_hex_len (buf, len); +memcpy (dest, buf, ll); + dest += ll; + buf += ll; + len -= ll;
Why not make it simpler?
while (!ishex(buf[i])) dest[i] = buf[i++];
builtin-rewrite-commits.c line 203
Quoted 1 line
builtin-rewrite-commits.c new file +1
-0+ ll =hex_len (buf, len);
It is really shorter (because you spare the whole hex_len() function, to say
for (ll = 0; i + ll < len && ishex(buf[i + ll]); ll++) ; /* do nothing */
builtin-rewrite-commits.c line 204
Quoted 1 line
builtin-rewrite-commits.c new file +1
-0+ if (ll >= 8 && ll <= 40 &&
AFAICT our abbreviation allows for 4 characters and up. Default abbreviation is 7, IIRC.
builtin-rewrite-commits.c line 209
Quoted 5 lines
builtin-rewrite-commits.c new file +5
-0+ !get_short_sha1(buf, ll, sha1, 1) && + !get_rewritten_sha1(sha1)) +memcpy (dest,sha1_to_hex (sha1), ll); + else +memcpy (dest ,buf ,ll );
What do you do if the rewritten sha1, truncated to ll characters, is ambiguous? Wouldn't you need more than
builtin-rewrite-commits.c line 239
Quoted 10 lines
builtin-rewrite-commits.c new file +10
-0+static int is_ref_to_be_rewritten (const char *ref) +{ +unsigned char sha1[20 ]; +int flag; + +if (prefixcmp (ref,"refs/" )) +return 0 ; +if (!prefixcmp (ref,"refs/remotes/" )) +return 0 ; +if (!prefixcmp (ref+5 , original_prefix))
Should original_prefix not be "refs/original", then?
builtin-rewrite-commits.c line 252
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+static int is_pruned (struct commit *commit,int path_pruning) +{ +if (commit->object.flags &PRUNED ) +return 1 ;
Hmm. I thought about changing get_revision_1() to mark that commit as uninteresting, since the parents were already added. But I guess this has too much side effect potential.
In any case, I think that "NO_MATCH" would be a more descriptive name.
builtin-rewrite-commits.c line 255
Quoted 3 lines
builtin-rewrite-commits.c new file +3
-0+if (path_pruning && + !(commit->object.flags & (TREECHANGE |UNINTERESTING ))) +return 1 ;
Why only with "path_pruning"? Ah yes. Because otherwise, you would assume "A" in "A..B" to be pruned. But what do you do if someone says
git rewrite-commits A.. x/y
because she wants _only_ commits later than A rewritten, but everything from A backwards kept as-is?
If I understand your code correctly, the given command would cut off the history at A.
I wonder why you bother at all: my impression was that the revisions you want to filter out here were already filtered out by revision.c:rewrite_parents()...
builtin-rewrite-commits.c line 264
Quoted 6 lines
builtin-rewrite-commits.c new file +6
-0+static void rewrite_sha1 (struct object *obj,unsigned char *new_sha1) +{ +if (!hashcmp (obj->sha1, new_sha1)) +return ; + +add_rewrite_decoration (obj, new_sha1);
This is not so much "rewrite_sha1", as "append_rewritten_sha1", right?
Quoted 5 lines
+/*
+ * Replace any parent that has been removed by its parents
+ * and return the number of new parents.
+ * We directly modify the parent list, so any libification
+ * should probably adapt this function.
I do not think that this code will be libified any time soon.
Quoted 1 line
+static int
rewrite_parents(struct commit *commit, int path_pruning)
Of course, you could always pass a "struct commit_list **rewritten_parents_p" to this function.
builtin-rewrite-commits.c line 292
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+get_rewritten_sha1 (sha1); +if (!is_null_sha1 (sha1)) { +hashclr (sha1); +rewrite_sha1 (&list->item->object, sha1);
I guess you'll admit that it is unintuitive to read "get_rewritten_sha1(sha1); rewrite_sha1(o, sha1);". I thought: "What? Again?" IMHO that is a strong hint that "rewrite_sha1" is not an apt name for that function.
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+static int rewrite_ref (const char *refname,const unsigned char *sha1, +int flags,void *cb_data) +{ +int prefix_len;
builtin-rewrite-commits.c line 329
Quoted 10 lines
builtin-rewrite-commits.c new file +10
-0+int len; +char buffer[256 ], *p; +struct object *obj =parse_object (sha1); +unsigned char new_sha1[20 ]; +struct commit *commit; +int pruned; + +if (!obj) +return 0 ; +if (obj->type ==OBJ_TAG )
Speaking of tags... We will have to add (in a separate patch, to keep things reviewable) a method to rewrite them, too.
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (!is_ref_to_be_rewritten(refname)) + return 0;
Hmm. When looking at that code, I wonder if
git rewrite-commits A..B
will rewrite C, too, if it happens to lie in A..B. That would be not brilliant.
I guess you will need to copy the positive refs in revs->pending, if there are any, and later _not_ call for_each_ref if that list was empty.
builtin-rewrite-commits.c line 339
Quoted 6 lines
builtin-rewrite-commits.c new file +6
-0+ commit =lookup_commit_reference (sha1); + pruned =is_pruned (commit, !!cb_data); + +hashcpy (new_sha1, sha1); +if (!pruned &&get_rewritten_sha1 (new_sha1)) +return 0 ;
So if pruned == 1, you _do_ rewrite it? I'm not quite sure. Care to explain?
Quoted 18 lines
builtin-rewrite-commits.c new file +18
-0+static void filter_and_write_commit (char *commit_body,size_t len, +struct commit *commit,unsigned char *sha1) +{ +char commit_path[PATH_MAX ]; +struct child_process cmd; +int argc; +const char *argv[10 ]; +int fd; +const char *env[] = { commit_env,NULL }; +char hex[41 ]; +struct commit_list *list =NULL , **end = &list; + +memcpy (commit_env+sizeof (commit_env)-41 , +sha1_to_hex (commit->object.sha1),40 ); + + fd =git_mkstemp (commit_path,sizeof (commit_path),".commit_XXXXXX" );; +write_or_die (fd, commit_body, len); +
builtin-rewrite-commits.c line 427
Quoted 10 lines
builtin-rewrite-commits.c new file +10
-0+ argc =0 ; + argv[argc++] ="sh" ; + argv[argc++] ="-c" ; + argv[argc++] = commit_filter; + argv[argc] =NULL ; +memset (&cmd,0 ,sizeof (cmd)); + cmd.in =open (commit_path,O_RDONLY ); +if (cmd.in <0 ) +die ("Unable to read commit from file '%s'" , commit_path); +unlink (commit_path);
This will fail on Windows. You do not catch that error, so it is almost
fine: just put the file into rewrite_dir, so the leftovers will be removed later anyway.
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+hashclr (sha1); + commit->object.flags |=PRUNED ; +/* +* If the filter returns two or more commits,
builtin-rewrite-commits.c line 463
Quoted 10 lines
builtin-rewrite-commits.c new file +10
-0+* we consider the original commit to have been +* removed and put the list in the old commit's +* parent list so that all the old commit's children +* will copy them. +*/ +if (list) { +free_commit_list (commit->parents); + commit->parents = list; + }else +add_sha1_map (commit->object.sha1,NULL );
That is almost certainly wrong. If you step away from the notion that get_rewritten_sha1() returns _one_ SHA-1, all will become clearer. And the filters should know about them SHA-1s, too.
builtin-rewrite-commits.c line 481
Quoted 2 lines
builtin-rewrite-commits.c new file +2
-0+/* Make enough remove for n (possibly extra) parents */ + p = buf =xmalloc (orig_len + n*48 );
As stated above, I'd prefer ALLOC_GROW().
builtin-rewrite-commits.c line 490
Quoted 9 lines
builtin-rewrite-commits.c new file +9
-0+ p =rewrite_header (p, &orig_len, &orig_buf, commit); + p =rewrite_body (p, orig_len, orig_buf); +if (!commit_filter) { +if (write_sha1_file (buf, p-buf, commit_type, sha1)) +die ("Unable to write new commit" ); +add_sha1_map (commit->object.sha1, sha1); + }else +filter_and_write_commit (buf, p-buf, commit, sha1); +free (buf);
You can really discard the commit->buffer, too, no?
builtin-rewrite-commits.c line 547
Quoted 6 lines
builtin-rewrite-commits.c new file +5
-0+ +rewrite_sha1 (&commit->object, sha1); +} +static char aux_functions[] = +"export GIT_REWRITE_DIR=`pwd`\n"
Better put the correct absolute path there.
Quoted 7 lines
+"commit()\n"
+"{\n"
+" git-hash-object -w -t commit --stdin\n"
+"}\n"
+"map()\n"
+"{\n"
+" # if it was not rewritten, take the original\n"
Quoted 8 lines
+" if test -r \"$GIT_REWRITE_DIR/map/$1\"\n"
+" then\n"
+" cat \"$GIT_REWRITE_DIR/map/$1\"\n"
+" else\n"
+" echo \"$1\"\n"
+" fi\n"
+"}\n"
+"cd t\n";
Then you do not need this extra fork() and cd all the time the filters source the helper file.
You do not even need the one static global buffer, if you put that script into the function writing it, inside an fprintf() call.
Quoted 1 line
+static char filter_prefix[] = ". aux;";
And here, I'd put the absolute path, too.
builtin-rewrite-commits.c line 575
Quoted 10 lines
builtin-rewrite-commits.c new file +10
-0+static char *create_filter (const char *command) +{ +int prefix_len =sizeof (filter_prefix)-1 ; +int command_len =strlen (command); +char *filter =xmalloc (prefix_len + command_len +1 ); + +memcpy (filter, filter_prefix, prefix_len); +memcpy (filter+prefix_len, command, command_len+1 ); +return filter; +}
I really like that approach. This makes it so much more convenient for users.
builtin-rewrite-commits.c line 628
Quoted 9 lines
builtin-rewrite-commits.c new file +9
-0+static void setup_temp_dir () +{ +int aux; + + absolute_git_dir =create_absolute_path (get_git_dir ()); +setenv (GIT_DIR_ENVIRONMENT , absolute_git_dir,1 ); + +if (!rewrite_dir) { + rewrite_dir =xstrdup (git_path ("rewrite" ));
I might read the code wrong, but this does not guarantee that rewrite_dir is an absolute path, right?
builtin-rewrite-commits.c line 639
Quoted 2 lines
builtin-rewrite-commits.c new file +2
-0+if (mkdir (mkpath ("%s/map" , rewrite_dir),0777 )) +die ("unable to create map directory '%s/map'" , rewrite_dir);
Maybe make this dependent on --write-sha1-mappings, and have a check in "map ()"?
builtin-rewrite-commits.c line 685
Quoted 5 lines
builtin-rewrite-commits.c new file +5
-0+if (index_filter || commit_filter) +setup_temp_dir (); +else +/* They'll never know. BWUHAHA */ + write_sha1_mapping =0 ;
I like the comment ;-)
builtin-rewrite-commits.c line 695
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+prepare_revision_walk (&rev); +while ((commit =get_revision (&rev)) !=NULL ) { +rewrite_commit (commit, !!rev.prune_fn); + }
Please lose the curly brackets for single lines; otherwise it would look too perl like.
builtin-rewrite-commits.c line 704
Quoted 1 line
builtin-rewrite-commits.c new file +1
-0+rm_rf (git_path ("refs/%s" , original_prefix));
Would it not be better to move refs/original to refs/original/original?
Pooh. A lot of comments. Please take that as a sign that I am interested in rewrite-commits. BTW did I mention already that I like the name "rewrite-commits"?
Ciao,
Dscho
Re: [PATCH 6/6] Add git-rewrite-commits
Quoted 1 line · Johannes Schindelin
Pooh. A lot of comments. Please take that as a sign that I am interested
Thanks. I'll look through them tomorrow.
Quoted 2 lines
in rewrite-commits. BTW did I mention already that I like the name "rewrite-commits"?
You should like it. You suggested it.
(http://article.gmane.org/gmane.comp.version-control.git/45637)
Not that I had read that when I named it. I'm about 2.5 months behind on my git mailing list reading.
skimo
Re: [PATCH 6/6] Add git-rewrite-commits
In reply to Johannes SchindelinQuoted 4 lines · Johannes Schindelin
Quoted 1 line · On Thu, 12 Jul 2007, [email protected] wrote:
+#include "
grep.h"I did not compile test, but do you really need that?
Not anymore.
Quoted 4 lines
Quoted 4 lines
builtin-rewrite-commits.c new file +3
-0+struct decoration rewrite_decoration = {"rewritten as" }; + +struct rewrite_decoration {
Quoted 8 lines
builtin-rewrite-commits.c line 24
Quoted 3 lines
builtin-rewrite-commits.c new file +3
-0+struct rewrite_decoration *next; +unsigned char sha1[20 ]; +};I wonder why you give the instance of a "struct decoration" the same name as that of a _different_ struct. IOW it is confusing that there is a "struct
rewrite_decoration", but the variable "rewrite_decoration" is no instance of that struct.
I was just following Linus's example.
Quoted 4 lines
Quoted 1 line
+static char *add_parents(char *dest, struct
commit_list*parents)Since one commit can be rewritten to multiple commits now, you do not know how much space you need to add the parents.
I count them beforehand.
Quoted 8 lines
builtin-rewrite-commits.c line 209
Quoted 5 lines
builtin-rewrite-commits.c new file +5
-0+ !get_short_sha1(buf, ll, sha1, 1) && + !get_rewritten_sha1(sha1)) +memcpy (dest,sha1_to_hex (sha1), ll); + else +memcpy (dest ,buf ,ll );What do you do if the rewritten sha1, truncated to ll characters, is ambiguous? Wouldn't you need more than
More than what?
Are you saying I should add some more of it then?
(As you can see, I simply don't consider that case here, so right now I just leave it possibly ambiguous.)
Quoted 3 lines
builtin-rewrite-commits.c line 239
Quoted 1 line
builtin-rewrite-commits.c new file +1
-0+if (!prefixcmp (ref+5 , original_prefix))Should
original_prefixnot be "refs/original", then?
The idea was that we could add a command line option later to override it.
Quoted 10 lines
builtin-rewrite-commits.c line 252
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+static int is_pruned (struct commit *commit,int path_pruning) +{ +if (commit->object.flags &PRUNED ) +return 1 ;Hmm. I thought about changing
get_revision_1()to mark that commit as uninteresting, since the parents were already added. But I guess this has too much side effect potential.In any case, I think that "
NO_MATCH" would be a more descriptive name.
Right now, it's only set for matching stuff, but it could be set for other kinds of pruning too.
Quoted 6 lines
builtin-rewrite-commits.c line 255
Quoted 3 lines
builtin-rewrite-commits.c new file +3
-0+if (path_pruning && + !(commit->object.flags & (TREECHANGE |UNINTERESTING ))) +return 1 ;Why only with "
path_pruning"? Ah yes. Because otherwise, you would assume "A" in "A..B" to be pruned.
TREECHANGE is only set when path pruning is in effect. If I didn't check for path_pruning, then all commits would be considered to have been pruned. (Or am I missing something? Honestyl, I found all that TREECHANGE stuff difficult to follow.)
revision.c itself is also riddled with "prune_fn && ". Wouldn't it make sense to invert the meaning of this bit and call it, say, PRUNED, so that the default is off and you would only have to check if the bit was set ?
Quoted 3 lines
I wonder why you bother at all: my impression was that the revisions you want to filter out here were already filtered out by revision.c:rewrite_parents()...
I also want to make reference that pointed to something that has been pruned (in either way) to now point to something in the new history.
Quoted 8 lines
builtin-rewrite-commits.c line 264
Quoted 6 lines
builtin-rewrite-commits.c new file +6
-0+static void rewrite_sha1 (struct object *obj,unsigned char *new_sha1) +{ +if (!hashcmp (obj->sha1, new_sha1)) +return ; + +add_rewrite_decoration (obj, new_sha1);This is not so much "
rewrite_sha1", as "append_rewritten_sha1", right?
Well, it's only called once on each commit.
Quoted 9 lines
builtin-rewrite-commits.c line 292
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+get_rewritten_sha1 (sha1); +if (!is_null_sha1 (sha1)) { +hashclr (sha1); +rewrite_sha1 (&list->item->object, sha1);I guess you'll admit that it is unintuitive to read "
get_rewritten_sha1(sha1);rewrite_sha1(o, sha1);". I thought: "What? Again?" IMHO that is a strong hint that "rewrite_sha1" is not an apt name for that function.
I guess our brains work in a slightly different way.
Quoted 6 lines
Hmm. When looking at that code, I wonder if
git rewrite-commits A..B
will rewrite C, too, if it happens to lie in A..B. That would be not brilliant.
That was the idea. Why is it not brilliant?
What would you like this to do instead?
Assume that in your new history all the commit that used to be pointed to have been removed. If these pointers are left to point to the old history, then how are you going to get at the new history?
Quoted 9 lines
builtin-rewrite-commits.c line 339
Quoted 6 lines
builtin-rewrite-commits.c new file +6
-0+ commit =lookup_commit_reference (sha1); + pruned =is_pruned (commit, !!cb_data); + +hashcpy (new_sha1, sha1); +if (!pruned &&get_rewritten_sha1 (new_sha1)) +return 0 ;So if pruned == 1, you _do_ rewrite it? I'm not quite sure. Care to explain?
Yes. See above.
Quoted 8 lines
builtin-rewrite-commits.c line 427
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+ cmd.in =open (commit_path,O_RDONLY ); +if (cmd.in <0 ) +die ("Unable to read commit from file '%s'" , commit_path); +unlink (commit_path);This will fail on Windows. You do not catch that error, so it is almost
fine: just put the file intorewrite_dir, so the leftovers will be removed later anyway.
You mean unlinking an opened file?
Quoted 17 lines
Quoted 5 lines
builtin-rewrite-commits.c new file +4
-0+hashclr (sha1); + commit->object.flags |=PRUNED ; +/* +* If the filter returns two or more commits, builtin-rewrite-commits.c line 463
Quoted 10 lines
builtin-rewrite-commits.c new file +10
-0+* we consider the original commit to have been +* removed and put the list in the old commit's +* parent list so that all the old commit's children +* will copy them. +*/ +if (list) { +free_commit_list (commit->parents); + commit->parents = list; + }else +add_sha1_map (commit->object.sha1,NULL );That is almost certainly wrong.
What specifically ?
Quoted 3 lines
If you step away from the notion that
get_rewritten_sha1()returns _one_ SHA-1, all will become clearer. And the filters should know about them SHA-1s, too.
The filters do know about them. The corresponding map file contains all the new SHA1s.
Quoted 6 lines
builtin-rewrite-commits.c line 490
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+add_sha1_map (commit->object.sha1, sha1); + }else +filter_and_write_commit (buf, p-buf, commit, sha1); +free (buf);You can really discard the
commit->buffer, too, no?
I'm not familiar enough with the internals to say for sure.
Quoted 4 lines
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+static void setup_temp_dir () +{ +int aux; +
Quoted 8 lines
builtin-rewrite-commits.c line 628
Quoted 5 lines
builtin-rewrite-commits.c new file +5
-0+ absolute_git_dir =create_absolute_path (get_git_dir ()); +setenv (GIT_DIR_ENVIRONMENT , absolute_git_dir,1 ); + +if (!rewrite_dir) { + rewrite_dir =xstrdup (git_path ("rewrite" ));I might read the code wrong, but this does not guarantee that
rewrite_diris an absolute path, right?
It doesn't right now.
Quoted 5 lines
builtin-rewrite-commits.c line 639
Quoted 2 lines
builtin-rewrite-commits.c new file +2
-0+if (mkdir (mkpath ("%s/map" , rewrite_dir),0777 )) +die ("unable to create map directory '%s/map'" , rewrite_dir);Maybe make this dependent on --write-sha1-mappings, and have a check in "map ()"?
I'll leave that to you :-)
Quoted 6 lines
builtin-rewrite-commits.c line 695
Quoted 3 lines
builtin-rewrite-commits.c new file +3
-0+while ((commit =get_revision (&rev)) !=NULL ) { +rewrite_commit (commit, !!rev.prune_fn); + }Please lose the curly brackets for single lines; otherwise it would look too perl like.
That would be
rewrite_commit($commit) while $commit = get_revision;
Quoted 3 lines
builtin-rewrite-commits.c line 704
Quoted 1 line
builtin-rewrite-commits.c new file +1
-0+rm_rf (git_path ("refs/%s" , original_prefix));Would it not be better to move refs/original to refs/original/original?
Is that what you want?
You'd end up with refs/original/original/original/original/original/original/original/ pretty quickly.
skimo
Re: [PATCH 6/6] Add git-rewrite-commits
Hi,
Quoted 15 lines · Sven Verdoolaege
Quoted 13 lines · Johannes Schindelin
builtin-rewrite-commits.c line 24
Quoted 7 lines · On Thu, 12 Jul 2007, [email protected] wrote:
builtin-rewrite-commits.c new file +6
-0+struct decoration rewrite_decoration = {"rewritten as" }; + +struct rewrite_decoration { +struct rewrite_decoration *next; +unsigned char sha1[20 ]; +};I wonder why you give the instance of a "struct decoration" the same name as that of a _different_ struct. IOW it is confusing that there is a "struct
rewrite_decoration", but the variable "rewrite_decoration" is no instance of that struct.
Quoted 1 line
I was just following Linus's example.
*Sigh* I hate to repeat arguments.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
+static char *add_parents(char *dest, struct
commit_list*parents)Since one commit can be rewritten to multiple commits now, you do not know how much space you need to add the parents.
I count them beforehand.
Yes. And it is extremely hard to follow through your code, just to verify that it really works. Using ALLOC_GROW instead of trying to play cute games would spare these tours, and I am quite convinced that it makes for less bugs. If not now, then when somebody _else_ than you touches the code.
Quoted 10 lines
Quoted 8 lines
builtin-rewrite-commits.c line 209
Quoted 5 lines
builtin-rewrite-commits.c new file +5
-0+ !get_short_sha1(buf, ll, sha1, 1) && + !get_rewritten_sha1(sha1)) +memcpy (dest,sha1_to_hex (sha1), ll); + else +memcpy (dest ,buf ,ll );What do you do if the rewritten sha1, truncated to ll characters, is ambiguous? Wouldn't you need more than
More than what?
Right. I did not complete that sentence. But isn't it obvious? Usually, you put in short, but (at least for some time) _unambiguous_ short names. IMHO people would expect the same to be true of rewritten commit messages.
Quoted 3 lines
Are you saying I should add some more of it then? (As you can see, I simply don't consider that case here, so right now I just leave it possibly ambiguous.)
Yes, I saw that. Just wanted to remind you that some people might consider this a bug.
Quoted 6 lines
Quoted 3 lines
builtin-rewrite-commits.c line 239
Quoted 1 line
builtin-rewrite-commits.c new file +1
-0+if (!prefixcmp (ref+5 , original_prefix))Should
original_prefixnot be "refs/original", then?The idea was that we could add a command line option later to override it.
Okay, I'll try again. You do not use the canonical form. Why not use it, if only for consistency? Besides, if you want to be able to override it with a command line option, you _will_ have to canonicalise _that_ original_prefix.
Quoted 9 lines
Quoted 9 lines
builtin-rewrite-commits.c line 252
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+static int is_pruned (struct commit *commit,int path_pruning) +{ +if (commit->object.flags &PRUNED ) +return 1 ;Hmm. I thought about changing
get_revision_1()to mark that commit as uninteresting, since the parents were already added. But I guess this has too much side effect potential.
Quoted 4 lines
Quoted 1 line
In any case, I think that "
NO_MATCH" would be a more descriptive name.Right now, it's only set for matching stuff, but it could be set for other kinds of pruning too.
Yes, it could.
Quoted 11 lines
Quoted 6 lines
builtin-rewrite-commits.c line 255
Quoted 3 lines
builtin-rewrite-commits.c new file +3
-0+if (path_pruning && + !(commit->object.flags & (TREECHANGE |UNINTERESTING ))) +return 1 ;Why only with "
path_pruning"? Ah yes. Because otherwise, you would assume "A" in "A..B" to be pruned.TREECHANGE is only set when path pruning is in effect. If I didn't check for
path_pruning, then all commits would be considered to have been pruned. (Or am I missing something? Honestyl, I found all that TREECHANGE stuff difficult to follow.)
AFAICT TREECHANGE means that parents were rewritten.
Quoted 4 lines
revision.citself is also riddled with "prune_fn&& ". Wouldn't it make sense to invert the meaning of this bit and call it, say, PRUNED, so that the default is off and you would only have to check if the bit was set ?
You meant the TREECHANGE bit? No.
BTW what do you plan to do about my objection to UNINTERESTING, given the example "git rewrite-commits A..B x/y"?
Quoted 7 lines
Quoted 3 lines
I wonder why you bother at all: my impression was that the revisions you want to filter out here were already filtered out by revision.c:rewrite_parents()...
I also want to make reference that pointed to something that has been pruned (in either way) to now point to something in the new history.
I did not understand that intention. Maybe I am too dumb, that's all.
Quoted 10 lines
Quoted 8 lines
builtin-rewrite-commits.c line 264
Quoted 6 lines
builtin-rewrite-commits.c new file +6
-0+static void rewrite_sha1 (struct object *obj,unsigned char *new_sha1) +{ +if (!hashcmp (obj->sha1, new_sha1)) +return ; + +add_rewrite_decoration (obj, new_sha1);This is not so much "
rewrite_sha1", as "append_rewritten_sha1", right?Well, it's only called once on each commit.
Didn't I mention that it was a severe limitation to think of the sha1 mapping of a 1-to-1 mapping? Think of it more as a relation.
Quoted 11 lines
Quoted 9 lines
builtin-rewrite-commits.c line 292
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+get_rewritten_sha1 (sha1); +if (!is_null_sha1 (sha1)) { +hashclr (sha1); +rewrite_sha1 (&list->item->object, sha1);I guess you'll admit that it is unintuitive to read "
get_rewritten_sha1(sha1);rewrite_sha1(o, sha1);". I thought: "What? Again?" IMHO that is a strong hint that "rewrite_sha1" is not an apt name for that function.I guess our brains work in a slightly different way.
I doubt that. What would you expect a code
get_tagged_commit(commit); tag_commit(tag, commit);
to do, if not tag a tagged commit _again_? So I bet if it wasn't your code to begin with, you would have experienced the same confusion as me.
Quoted 8 lines
Quoted 6 lines
Hmm. When looking at that code, I wonder if
git rewrite-commits A..B
will rewrite C, too, if it happens to lie in A..B. That would be not brilliant.
That was the idea. Why is it not brilliant?
Because it is called rewrite-commits, not
rewrite-all-refs-that-touch-this-commit-range.
Quoted 1 line
What would you like this to do instead?
Only touch the positive refs given in the command line. If you say "--all", then it's all. If you say "A..B", then it's "B".
Quoted 3 lines
Assume that in your new history all the commit that used to be pointed to have been removed. If these pointers are left to point to the old history, then how are you going to get at the new history?
I still have the superproject splitting as the main application in mind. Only for big applications like these does the performance improvement of rewrite-commits over filter-branch buy us anything.
Quoted 11 lines
Quoted 9 lines
builtin-rewrite-commits.c line 339
Quoted 6 lines
builtin-rewrite-commits.c new file +6
-0+ commit =lookup_commit_reference (sha1); + pruned =is_pruned (commit, !!cb_data); + +hashcpy (new_sha1, sha1); +if (!pruned &&get_rewritten_sha1 (new_sha1)) +return 0 ;So if pruned == 1, you _do_ rewrite it? I'm not quite sure. Care to explain?
Yes. See above.
Sorry, this explanation does not help me. My impression was that a pruned commit should be _mapped_ to the rewritten sha1s of the original parents, but not be rewritten.
Quoted 10 lines
Quoted 8 lines
builtin-rewrite-commits.c line 427
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+ cmd.in =open (commit_path,O_RDONLY ); +if (cmd.in <0 ) +die ("Unable to read commit from file '%s'" , commit_path); +unlink (commit_path);This will fail on Windows. You do not catch that error, so it is almost
fine: just put the file intorewrite_dir, so the leftovers will be removed later anyway.You mean unlinking an opened file?
Yes, I mean unlinking an opened file.
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
builtin-rewrite-commits.c new file +8
-0+hashclr (sha1); + commit->object.flags |=PRUNED ; +/* +* If the filter returns two or more commits, +* we consider the original commit to have been +* removed and put the list in the old commit's +* parent list so that all the old commit's children +* will copy them. Quoted 8 lines
builtin-rewrite-commits.c line 463
Quoted 6 lines
builtin-rewrite-commits.c new file +6
-0+*/ +if (list) { +free_commit_list (commit->parents); + commit->parents = list; + }else +add_sha1_map (commit->object.sha1,NULL );That is almost certainly wrong.
Quoted 1 line
What specifically ?
It takes a few minutes to verify that the correct calls to add_sha1_map() are done in every case.
Also, why should commit->parents be reset only in the multiple-sha1 case?
But most seriously, why do you replace the _parents_ of a given commit by the sha1s of the _rewritten_ commits? They are not even the rewritten _parents_.
Quoted 6 lines
Quoted 3 lines
If you step away from the notion that
get_rewritten_sha1()returns _one_ SHA-1, all will become clearer. And the filters should know about them SHA-1s, too.The filters do know about them. The corresponding map file contains all the new SHA1s.
But the code does not reflect that in some parts. For example when you call "get_rewritten_sha1(sha1);" which one is it? And what is it if the commit was rewritten to no commit at all, i.e. the history was cut forcefully?
Quoted 8 lines
Quoted 6 lines
builtin-rewrite-commits.c line 490
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+add_sha1_map (commit->object.sha1, sha1); + }else +filter_and_write_commit (buf, p-buf, commit, sha1); +free (buf);You can really discard the
commit->buffer, too, no?I'm not familiar enough with the internals to say for sure.
Hmm. You play with them pretty heavily, then, for example when you just reset commit->parents.
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
builtin-rewrite-commits.c new file +4
-0+static void setup_temp_dir () +{ +int aux; +Quoted 8 lines
builtin-rewrite-commits.c line 628
Quoted 5 lines
builtin-rewrite-commits.c new file +5
-0+ absolute_git_dir =create_absolute_path (get_git_dir ()); +setenv (GIT_DIR_ENVIRONMENT , absolute_git_dir,1 ); + +if (!rewrite_dir) { + rewrite_dir =xstrdup (git_path ("rewrite" ));I might read the code wrong, but this does not guarantee that
rewrite_diris an absolute path, right?
Quoted 1 line
It doesn't right now.
Umm. Sorry to ask so bluntly: are you planning to change that?
Quoted 7 lines
Quoted 5 lines
builtin-rewrite-commits.c line 639
Quoted 2 lines
builtin-rewrite-commits.c new file +2
-0+if (mkdir (mkpath ("%s/map" , rewrite_dir),0777 )) +die ("unable to create map directory '%s/map'" , rewrite_dir);Maybe make this dependent on --write-sha1-mappings, and have a check in "map ()"?
I'll leave that to you :-)
IMHO the first part should be in the initial commit of builtin-rewrite-commits.c, so I will not do that.
Quoted 10 lines
Quoted 6 lines
builtin-rewrite-commits.c line 695
Quoted 3 lines
builtin-rewrite-commits.c new file +3
-0+while ((commit =get_revision (&rev)) !=NULL ) { +rewrite_commit (commit, !!rev.prune_fn); + }Please lose the curly brackets for single lines; otherwise it would look too perl like.
That would be
rewrite_commit($commit) while $commit = get_revision;
No, it would not, because it is not valid C.
Quoted 8 lines
Quoted 4 lines
builtin-rewrite-commits.c line 704
Quoted 1 line
builtin-rewrite-commits.c new file +1
-0+rm_rf (git_path ("refs/%s" , original_prefix));Would it not be better to move refs/original to
refs/original/original?Is that what you want? You'd end up with refs/original/original/original/original/original/original/original/ pretty quickly.
We are pretty anal about not losing data too quickly, and possibly unwantedly.
It would be surprising to me if this would be the first program to change that behaviour.
IOW, refs/original/ is not a temporary directory that you easily blow away. It is meant for the user to be inspected. And it is the user's obligation to say when that happened, and that it should go now.
Thinking about it again, I'd even go so far as to disallow operation with an existing refs/original/.
Ciao,
Dscho
Re: [PATCH 6/6] Add git-rewrite-commits
Quoted 8 lines · Johannes Schindelin
Quoted 7 lines · Sven Verdoolaege
Quoted 6 lines
builtin-rewrite-commits.c line 255
Quoted 3 lines
builtin-rewrite-commits.c new file +3
-0+if (path_pruning && + !(commit->object.flags & (TREECHANGE |UNINTERESTING ))) +return 1 ;Why only with "
path_pruning"? Ah yes. Because otherwise, you would assume "A" in "A..B" to be pruned.
Quoted 6 lines
Quoted 4 lines
TREECHANGE is only set when path pruning is in effect. If I didn't check for
path_pruning, then all commits would be considered to have been pruned. (Or am I missing something? Honestly, I found all that TREECHANGE stuff difficult to follow.)AFAICT TREECHANGE means that parents were rewritten.
I think you'll find that if all commits touch a path in the path specifiers then all commits will have TREECHANGE set and so no parents will be rewritten.
Quoted 6 lines
Quoted 4 lines
revision.citself is also riddled with "prune_fn&& ". Wouldn't it make sense to invert the meaning of this bit and call it, say, PRUNED, so that the default is off and you would only have to check if the bit was set ?You meant the TREECHANGE bit? No.
Yes. Why?
Quoted 2 lines
BTW what do you plan to do about my objection to UNINTERESTING, given the example "git rewrite-commits A..B x/y"?
That was based on an apparent misunderstanding of my code that I tried to address above. I did not intend to do what you claim I do and a quick test confirms that my code does indeed not to what you claim it does.
More specifically, the history will not be cut off at A because A is marked UNINTERESTING and is therefore not considered to have been pruned.
A commit is considered pruned if it was either explicitly marked as such or if TREECHANGE is not set, but the later check (in is_pruned) is only done on commits that were checked for tree changes.
skimo
Re: [PATCH 6/6] Add git-rewrite-commits
Hi,
Quoted 14 lines · Sven Verdoolaege
Quoted 13 lines · Johannes Schindelin
Quoted 11 lines · Sven Verdoolaege
Quoted 6 lines
builtin-rewrite-commits.c line 255
Quoted 3 lines
builtin-rewrite-commits.c new file +3
-0+if (path_pruning && + !(commit->object.flags & (TREECHANGE |UNINTERESTING ))) +return 1 ;Why only with "
path_pruning"? Ah yes. Because otherwise, you would assume "A" in "A..B" to be pruned.TREECHANGE is only set when path pruning is in effect. If I didn't check for
path_pruning, then all commits would be considered to have been pruned. (Or am I missing something? Honestly, I found all that TREECHANGE stuff difficult to follow.)
Quoted 5 lines
Quoted 1 line
AFAICT TREECHANGE means that parents were rewritten.
I think you'll find that if all commits touch a path in the path specifiers then all commits will have TREECHANGE set and so no parents will be rewritten.
The code suggests otherwise.
But I really have to wonder: why do you play games with TREECHANGE? I had the impression that commit->parents is set appropriately by the revision walker, and that you do not have to do _anything_ for that to work.
Maybe the "--grep" thing does not yet. But then you should fix it in revision.c. Not in builtin-rewrite-commits.c
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
revision.citself is also riddled with "prune_fn&& ". Wouldn't it make sense to invert the meaning of this bit and call it, say, PRUNED, so that the default is off and you would only have to check if the bit was set ?You meant the TREECHANGE bit? No.
Yes. Why?
Why invert the meaning of a perfectly fine bit? Because you can? It is working right now, and it is not even a buglet, so what is there to fix?
Quoted 11 lines
Quoted 2 lines
BTW what do you plan to do about my objection to UNINTERESTING, given the example "git rewrite-commits A..B x/y"?
That was based on an apparent misunderstanding of my code that I tried to address above. I did not intend to do what you claim I do and a quick test confirms that my code does indeed not to what you claim it does.
More specifically, the history will not be cut off at A because A is marked UNINTERESTING and is therefore not considered to have been pruned.
Why do you test for TREECHANGE | UNINTERESTING then?
Quoted 3 lines
A commit is considered pruned if it was either explicitly marked as such or if TREECHANGE is not set, but the later check (in
is_pruned) is only done on commits that were checked for tree changes.
I don't understand. What do you mean by "a commit is pruned"? Does it mean that this commit was left out from the revision walk? What does that have to do with TREECHANGE, which means that the parents set was modified?
Ciao,
Dscho
Re: [PATCH 6/6] Add git-rewrite-commits
Quoted 11 lines · Johannes Schindelin
Hi,
Quoted 7 lines · Sven Verdoolaege
Quoted 6 lines · Johannes Schindelin
Quoted 4 lines · Sven Verdoolaege
TREECHANGE is only set when path pruning is in effect. If I didn't check for
path_pruning, then all commits would be considered to have been pruned. (Or am I missing something? Honestly, I found all that TREECHANGE stuff difficult to follow.)
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
AFAICT TREECHANGE means that parents were rewritten.
I think you'll find that if all commits touch a path in the path specifiers then all commits will have TREECHANGE set and so no parents will be rewritten.
The code suggests otherwise.
Check again.
Quoted 3 lines
But I really have to wonder: why do you play games with TREECHANGE? I had the impression that
commit->parentsis set appropriately by the revision walker,
Only for unpruned commits and the references (explicitly specified on the command line if you wish) may have been pruned.
Quoted 11 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
revision.citself is also riddled with "prune_fn&& ". Wouldn't it make sense to invert the meaning of this bit and call it, say, PRUNED, so that the default is off and you would only have to check if the bit was set ?You meant the TREECHANGE bit? No.
Yes. Why?
Why invert the meaning of a perfectly fine bit? Because you can? It is working right now, and it is not even a buglet, so what is there to fix?
Because it is confusing. As explained above, the bit doesn't have a meaning of its own. You can only interpret the bit if some other conditions are met.
It would be even more confusing if it meant what you claim it means.
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
BTW what do you plan to do about my objection to UNINTERESTING, given the example "git rewrite-commits A..B x/y"?
That was based on an apparent misunderstanding of my code that I tried to address above. I did not intend to do what you claim I do and a quick test confirms that my code does indeed not to what you claim it does.
Quoted 5 lines
Quoted 3 lines
More specifically, the history will not be cut off at A because A is marked UNINTERESTING and is therefore not considered to have been pruned.
Why do you test for TREECHANGE | UNINTERESTING then?
Exactly for the reason mentioned above.
If the commit is marked UNINTERESTING then it has not been pruned, because it hasn't even been checked for TREECHANGE.
Quoted 7 lines
Quoted 3 lines
A commit is considered pruned if it was either explicitly marked as such or if TREECHANGE is not set, but the later check (in
is_pruned) is only done on commits that were checked for tree changes.I don't understand. What do you mean by "a commit is pruned"? Does it mean that this commit was left out from the revision walk? What does that have to do with TREECHANGE, which means that the parents set was modified?
You just claim that that is what it means. The code (see try_to_simplify_commit where the bit is set) and a simple experiment (explained above) show otherwise.
skimo
Re: [PATCH 6/6] Add git-rewrite-commits
In reply to Johannes SchindelinQuoted 2 lines · Johannes Schindelin
Didn't I mention that it was a severe limitation to think of the sha1 mapping of a 1-to-1 mapping? Think of it more as a relation.
The mapping is used in several operations.
First, there are several things that can happen to a commit
- it's pruned. This includes, for me, path pruning, matching and a commit filter returning no SHA1s.
- it's rewritten to another commit that can be considered the "moral equivalent" of that commit. This occurs when a commit is not pruned, but something else happened to the commit itself or one of its ancestors. This excludes, for me, the case where a commit filter returns more than one SHA1.
- it's replaced by more than one SHA1. This can only happen in a commit filter.
There are at least four operations in which this mapping is used:
- if the parents of a commit have been rewritten to one or more commits, then they are replaced by the new commits. If any parent has been pruned, then it is replaced by the result of applying this operation on _its_ parents.
- any reference (in refs/) that points to a rewritten or pruned commit is removed and
* if the commit was rewritten to a single commit, then it is replaced by this commit
* otherwise, there is no moral equivalent single commit, but we want to ensure we can still access the new commits, so I create several references, either to each of the many commits the old commit was rewritten to, or to each of its nearest unpruned ancestors (i.e., the same set as described in the previous operation).
- a SHA1 of a commit that appears in a commit message is replaced by the rewritten commit iff it was rewritten to a single commit. That is, if the commit was pruned or rewritten (through a commit filter to more than one commit), then the SHA1 is left alone.
- the mapping available to filters
* if the commit was pruned, an empty file is created
* otherwise a file is created containing all rewritten SHA1s
I understand you want the second operation to only apply to refs explicitly mentioned on the command line. What else would you like to change?
skimo
Re: [PATCH 6/6] Add git-rewrite-commits
Quoted 4 lines · Sven Verdoolaege
- a SHA1 of a commit that appears in a commit message is replaced by the rewritten commit iff it was rewritten to a single commit. That is, if the commit was pruned or rewritten (through a commit filter) to more than one commit, then the SHA1 is left alone.
Sorry. I misremembered. I considered doing it this way, but then thought it was better to replace the SHA1 with a(n abbreviated) null SHA1 to signify that the commit had gone.
skimo
Re: [PATCH 6/6] Add git-rewrite-commits
Hi,
Quoted 9 lines · Sven Verdoolaege
Quoted 4 lines · Sven Verdoolaege
- a SHA1 of a commit that appears in a commit message is replaced by the rewritten commit iff it was rewritten to a single commit. That is, if the commit was pruned or rewritten (through a commit filter) to more than one commit, then the SHA1 is left alone.
Sorry. I misremembered. I considered doing it this way, but then thought it was better to replace the SHA1 with a(n abbreviated) null SHA1 to signify that the commit had gone.
Yes. This shows that you did not get my objection. The commit is not replaced with _no_ commits, but with _multiple_ commits.
Ciao,
Dscho
Re: [PATCH 6/6] Add git-rewrite-commits
In reply to Sven VerdoolaegeHi,
Quoted 9 lines · Sven Verdoolaege
Quoted 2 lines · Johannes Schindelin
Didn't I mention that it was a severe limitation to think of the sha1 mapping of a 1-to-1 mapping? Think of it more as a relation.
The mapping is used in several operations.
First, there are several things that can happen to a commit- it's pruned. This includes, for me, path pruning, matching and a commit filter returning no SHA1s.
Okay.
Quoted 5 lines
- it's rewritten to another commit that can be considered the "moral equivalent" of that commit. This occurs when a commit is not pruned, but something else happened to the commit itself or one of its ancestors. This excludes, for me, the case where a commit filter returns more than one SHA1.
Okay. For me it does not at all exclude that. If I want to replace a commit by no commit, I write a commit-filter which does not return anything. If I return more than one SHA1s, I damned well want all of those be the replacement "commit".
To say "the" replacement "commit", means to mistake the mapping as a function, a non-relation.
Quoted 2 lines
- it's replaced by more than one SHA1. This can only happen in a commit filter.
For the moment, yes.
Quoted 4 lines
There are at least four operations in which this mapping is used:
- if the parents of a commit have been rewritten to one or more commits, then they are replaced by the new commits.
Yes, that is the primary use for the mapping.
Quoted 2 lines
If any parent has been pruned, then it is replaced by the result of applying this operation on _its_ parents.
Why? This is overy complicated. If a commit has been pruned, why does the mapping not point to the _non-pruned_ parent? IOW if you have something like this:
A - B - C - D - E - F
and all commits except A and F are pruned, the mapping for A, B, C, D and E should _all_ point to the (possibly rewritten) A.
Quoted 10 lines
- any reference (in refs/) that points to a rewritten or pruned commit is removed and
* if the commit was rewritten to a single commit, then it is replaced by this commit
* otherwise, there is no moral equivalent single commit, but we want to ensure we can still access the new commits, so I create several references, either to each of the many commits the old commit was rewritten to, or to each of its nearest unpruned ancestors (i.e., the same set as described in the previous operation).
I'd argue that it should be an error if a to-be-rewritten ref (and I still strongly disagree with you that all refs should be rewritten) would point to multiple commits. Possibly overridable with "--allow-octopus-refs". But the default should be to error out.
Quoted 4 lines
- a SHA1 of a commit that appears in a commit message is replaced by the rewritten commit iff it was rewritten to a single commit. That is, if the commit was pruned or rewritten (through a commit filter to more than one commit), then the SHA1 is left alone.
Both this behaviour and the one you described in your reply are wrong.
Quoted 3 lines
- the mapping available to filters
* if the commit was pruned, an empty file is created
* otherwise a file is created containing all rewritten SHA1s
As I stated above: it is utterly wrong to create an empty mapping for a commit that was pruned. It does not take long to think of an example:
A - B - C - D
Now, A and D get pruned. Do you want the whole branch to vanish? _Hell, no_.
Quoted 2 lines
I understand you want the second operation to only apply to refs explicitly mentioned on the command line.
You have to at least give the users a chance to grasp what they are doing. And if that means to change the semantics to something saner, then so be it.
Ciao,
Dscho
Re: [PATCH 6/6] Add git-rewrite-commits
Quoted 4 lines · Johannes Schindelin
Okay. For me it does not at all exclude that. If I want to replace a commit by no commit, I write a commit-filter which does not return anything. If I return more than one SHA1s, I damned well want all of those be the replacement "commit".
So how about you telling me what it _means_ for one commit to be replaced by more than one commit or at least giving me an example?
Quoted 10 lines
Quoted 2 lines
- if the parents of a commit have been rewritten to one or more commits, then they are replaced by the new commits.
Yes, that is the primary use for the mapping.
Quoted 2 lines
If any parent has been pruned, then it is replaced by the result of applying this operation on _its_ parents.
Why? This is overy complicated. If a commit has been pruned, why does the mapping not point to the _non-pruned_ parent?
It may not have any non-pruned parents and for the pruned ones, we wouldn't want to lose the relation with the non-pruned ancestors.
Quoted 7 lines
IOW if you have
something like this:A - B - C - D - E - F
and all commits except A and F are pruned, the mapping for A, B, C, D and E should _all_ point to the (possibly rewritten) A.
I'm not sure what you mean by "mapping" here, but the operation described above would make all of B, C, D, E and F have (the possibly rewritten) A as single parent (and parenthood was all I was talking about above).
Quoted 6 lines
Quoted 4 lines
- a SHA1 of a commit that appears in a commit message is replaced by the rewritten commit iff it was rewritten to a single commit. That is, if the commit was pruned or rewritten (through a commit filter to more than one commit), then the SHA1 is left alone.
Both this behaviour and the one you described in your reply are wrong.
So tell me what you would do then and why that would make sense.
Quoted 11 lines
Quoted 3 lines
- the mapping available to filters
* if the commit was pruned, an empty file is created
* otherwise a file is created containing all rewritten SHA1sAs I stated above: it is utterly wrong to create an empty mapping for a commit that was pruned. It does not take long to think of an example:
A - B - C - D
Now, A and D get pruned. Do you want the whole branch to vanish?
_Hell,no_.
Define "vanish" and, again, tell me what you would do.
Quoted 3 lines
You have to at least give the users a chance to grasp what they are doing. And if that means to change the semantics to something saner, then so be it.
Let's get things straight. I've added the map files and the possibility for a commit filter to return more than one commit because you asked me to. I've tried to make sense of it, but if you think the behavior I defined is not what it is supposed to be, then it is up to _you_ to tell me what you think it should be instead of letting me guess.
I think I'll just remove the possibility for the commit filter to return more than one SHA1 (or maybe even no SHA1s). filter-branch doesn't seem to allow either of those either.
skimo
Re: [PATCH 6/6] Add git-rewrite-commits
In reply to Johannes SchindelinQuoted 11 lines · Johannes Schindelin
Documentation/git-rewrite-commits.txt line 87
Quoted 8 lines
Documentation/git-rewrite-commits.txt new file +8
-0+Examples +-------- + +Suppose you want to remove a file (containing confidential information +or copyright violation) from all commits: + +---------------------------------------------------------------------------- +git rewrite-commits --index-filter 'git update-index --remove filename || :'We seem to prefer "$ git" instead of just "git" in the other man pages' examples.
"git update-index --remove Foo" does not remove the index entry Foo if the file Foo still exists in the working tree (use "git update-index --force-remove" for that).
But this leads to more fundamental issues. It is not obvious from the description what environment rewrite-commits runs in. Does it run at the toplevel of the current working tree, or is it run in a separate temporary directory like filter-branch does? What "index" and "HEAD" do operations done by filters affect (I think it is safe to assume that readers familiar enough with other parts of git would be able to guess that filters should operate on the "HEAD" and index given by rewrite-commits to its execution environment without mucking with GIT_DIR nor GIT_INDEX_FILE)? Are filters allowed to modify files in the working tree, and if so what is the consequence of doing so?
Quoted 8 lines
Documentation/git-rewrite-commits.txt line 91
Quoted 4 lines
+----------------------------------------------------------------------------
Documentation/git-rewrite-commits.txt new file +3
-0+ +Now, you will get the rewritten history saved in your current branch +(the old branch is saved in refs/original).The "|| :" construct+ prevents the filter to fail when the given file was not present in the
+ index.
prevents the filter from failing? But is that really what we want? Why are we ignoring the error, and if there is a valid reason to ignore shouldn't we explain why?
Quoted 9 lines
Documentation/git-rewrite-commits.txt line 142
Quoted 9 lines
Documentation/git-rewrite-commits.txt new file +9
-0+To move the whole tree into a subdirectory, or remove it from there: + +--------------------------------------------------------------- +git rewrite-commits --index-filter \ + 'git ls-files -s | sed "s-\t-&newsubdir/-" | + GIT_INDEX_FILE=$GIT_INDEX_FILE.new \ + git update-index --index-info && + mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' +---------------------------------------------------------------
I see only one operation in the example, and "or remove it from there" confuses the reader.
I'll refrain from comments on the code right now, until I read the series over.
Re: [PATCH 6/6] Add git-rewrite-commits
Quoted 2 lines · Junio C Hamano
But this leads to more fundamental issues. It is not obvious from the description what environment rewrite-commits runs in.
I'll try to make that more clear in the next round.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Documentation/git-rewrite-commits.txt new file +4
-0+To move the whole tree into a subdirectory, or remove it from there: + +--------------------------------------------------------------- +git rewrite-commits --index-filter \
Quoted 8 lines
Quoted 5 lines
Documentation/git-rewrite-commits.txt line 142
Quoted 5 lines
Documentation/git-rewrite-commits.txt new file +5
-0+ 'git ls-files -s | sed "s-\t-&newsubdir/-" | + GIT_INDEX_FILE=$GIT_INDEX_FILE.new \ + git update-index --index-info && + mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' +---------------------------------------------------------------I see only one operation in the example, and "or remove it from there" confuses the reader.
I found it confusing too (I copied it from the filter-branch manual). I'll remove it.
skimo