{"thread":{"id":"25602","subject":"index rebuild for cloned repo","startedAt":"2010-10-31T17:44:30Z","lastAt":"2010-11-14T17:34:54Z","messageCount":16,"participants":["Pete Wyckoff","Jonathan Nieder","Andreas Schwab","Johannes Sixt","Nguyen Thai Ngoc Duy","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"154894","messageId":"20101031174430.GA30236@arf.padd.com","threadId":"25602","inReplyTo":null,"subject":"index rebuild for cloned repo","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2010-10-31T17:44:30Z","receivedAt":"2010-10-31T17:44:30Z","isPatch":false,"sender":{"key":"pw@padd.com","avatar":null},"body":"I'm trying to share pre-built working trees using NFS-server-side\nvolume cloning (not \"git clone\").  This makes a new volume that\nshares all the data with the source volume, including build\nproducts that would otherwise take hours to regenerate.  While\nthe data is identical, much of the inode information changes:\nuid, gid, ino, dev, mtime, ctime.\n\nWhat is the best way to rewrite .git/index in the clone?  Options\nthat work but are slow:\n\n    git reset --hard HEAD\n\twrite all files, breaking data sharing, 2 min 45 sec\n\n    git update-index --refresh\n\tstat and read all files, 5 min 55 sec\n\nI hacked out the file data comparison in ce_modified_check_fs()\nto measure:\n\n    HACKED git update-index --refresh\n\tJust the stat, 13 sec\n\nThe lstat() is required to look up the new inode number.\n\nThe rest of the clone operation takes around 3 min, so\nI'd like to avoid this additional 5+ min of read()s if\npossible.  Is there a way to do so using existing commands?\nShould I add a new option to update-index, or maybe write\na stand-alone tool to manipulate the index file directly?\n\nThanks,\n\n\t\t-- Pete\n\n\nP.S.  The user-observable problem that occurs if I do not\nrebuild the index is, e.g.:\n\n    $ git cherry-pick build/top\n    error: Your local changes to 'file.h' would be overwritten by merge.  Aborting.\n    Please, commit your changes or stash them before you can merge.\n"},{"id":"154896","messageId":"20101031180758.GC5683@burratino","threadId":"25602","inReplyTo":"20101031174430.GA30236@arf.padd.com","subject":"Re: index rebuild for cloned repo","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-10-31T18:07:58Z","receivedAt":"2010-10-31T18:07:58Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Pete,\n\nPete Wyckoff wrote:\n\n>                                                          While\n> the data is identical, much of the inode information changes:\n> uid, gid, ino, dev, mtime, ctime.\n> \n> What is the best way to rewrite .git/index in the clone?  Options\n> that work but are slow:\n> \n>     git reset --hard HEAD\n\nNot very good for this use case, as you noticed.\n\n>     git update-index --refresh\n> \tstat and read all files, 5 min 55 sec\n\nThat's better (better yet with -q).  The user-facing version is\n\"git add --refresh .\".\n\n[...]\n>     HACKED git update-index --refresh\n> \tJust the stat, 13 sec\n> \n> The lstat() is required to look up the new inode number.\n> \n> The rest of the clone operation takes around 3 min, so\n> I'd like to avoid this additional 5+ min of read()s if\n> possible.  Is there a way to do so using existing commands?\n> Should I add a new option to update-index\n\nYes, a new option sounds sane.\n\n> P.S.  The user-observable problem that occurs if I do not\n> rebuild the index is, e.g.:\n> \n>     $ git cherry-pick build/top\n>     error: Your local changes to 'file.h' would be overwritten by merge.  Aborting.\n>     Please, commit your changes or stash them before you can merge.\n\nThat's a bug.  In general, the \"high-level commands (porcelain)\"\nlisted in the git manpage (other than gitk) are supposed to hide an\nun-refreshed index from the user, generally by transparently\nrefreshing the index.\n\nThanks for reporting.\n\nHope that helps,\nJonathan\n"},{"id":"154898","messageId":"20101031195933.GA21240@burratino","threadId":"25602","inReplyTo":"20101031174430.GA30236@arf.padd.com","subject":"[PATCH] cherry-pick/revert: transparently refresh index","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-10-31T19:59:33Z","receivedAt":"2010-10-31T19:59:33Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"A stat-dirty index is not a detail that ought to concern the operator\nof porcelain such as \"git cherry-pick\".\n\nWithout this change, a cherry-pick after copying a worktree with rsync\nerrors out with a misleading message.\n\n\t$ git cherry-pick build/top\n\terror: Your local changes to 'file.h' would be overwritten by merge.  Aborting.\n\tPlease, commit your changes or stash them before you can merge.\n\nNoticed-by: Pete Wyckoff <pw@padd.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nPete Wyckoff wrote:\n\n> P.S.  The user-observable problem that occurs if I do not\n> rebuild the index is, e.g.:\n> \n>     $ git cherry-pick build/top\n>     error: Your local changes to 'file.h' would be overwritten by merge.  Aborting.\n>     Please, commit your changes or stash them before you can merge.\n\nMaybe this would help?\n\n builtin/revert.c              |   18 ++++++++++++++++--\n t/t3501-revert-cherry-pick.sh |   13 +++++++++++++\n 2 files changed, 29 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex 57b51e4..bb6e9e8 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -547,6 +547,21 @@ static void prepare_revs(struct rev_info *revs)\n \t\tdie(\"empty commit set passed\");\n }\n \n+static void read_and_refresh_cache(const char *me)\n+{\n+\tstatic struct lock_file index_lock;\n+\tint index_fd = hold_locked_index(&index_lock, 0);\n+\tif (read_index_preload(&the_index, NULL) < 0)\n+\t\tdie(\"git %s: failed to read the index\", me);\n+\trefresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL, NULL);\n+\tif (the_index.cache_changed) {\n+\t\tif (write_index(&the_index, index_fd) ||\n+\t\t    commit_locked_index(&index_lock))\n+\t\t\tdie(\"git %s: failed to refresh the index\", me);\n+\t}\n+\trollback_lock_file(&index_lock);\n+}\n+\n static int revert_or_cherry_pick(int argc, const char **argv)\n {\n \tstruct rev_info revs;\n@@ -567,8 +582,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \t\t\tdie(\"cherry-pick --ff cannot be used with --edit\");\n \t}\n \n-\tif (read_cache() < 0)\n-\t\tdie(\"git %s: failed to read the index\", me);\n+\tread_and_refresh_cache(me);\n \n \tprepare_revs(&revs);\n \ndiff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh\nindex bc7aedd..b210188 100755\n--- a/t/t3501-revert-cherry-pick.sh\n+++ b/t/t3501-revert-cherry-pick.sh\n@@ -81,6 +81,19 @@ test_expect_success 'revert after renaming branch' '\n \n '\n \n+test_expect_success 'revert on stat-dirty working tree' '\n+\tgit clone . repo &&\n+\t(\n+\t\tcd repo &&\n+\t\tgit checkout initial\n+\t) &&\n+\tcp -R repo copy &&\n+\t(\n+\t\tcd copy &&\n+\t\tgit cherry-pick added\n+\t)\n+'\n+\n test_expect_success 'revert forbidden on dirty working tree' '\n \n \techo content >extra_file &&\n-- \n1.7.2.3.557.gab647.dirty\n"},{"id":"154901","messageId":"m24oc2p0rd.fsf@igel.home","threadId":"25602","inReplyTo":"20101031195933.GA21240@burratino","subject":"Re: [PATCH] cherry-pick/revert: transparently refresh index","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2010-10-31T20:26:14Z","receivedAt":"2010-10-31T20:26:14Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh\n> index bc7aedd..b210188 100755\n> --- a/t/t3501-revert-cherry-pick.sh\n> +++ b/t/t3501-revert-cherry-pick.sh\n> @@ -81,6 +81,19 @@ test_expect_success 'revert after renaming branch' '\n>  \n>  '\n>  \n> +test_expect_success 'revert on stat-dirty working tree' '\n\nITYM s/revert/cherry-pick/\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"154902","messageId":"20101031203233.GA22937@burratino","threadId":"25602","inReplyTo":"m24oc2p0rd.fsf@igel.home","subject":"Re: [PATCH] cherry-pick/revert: transparently refresh index","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-10-31T20:32:33Z","receivedAt":"2010-10-31T20:32:33Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Andreas Schwab wrote:\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n\n>> --- a/t/t3501-revert-cherry-pick.sh\n>> +++ b/t/t3501-revert-cherry-pick.sh\n>> @@ -83,4 +83,17 @@ test_expect_success 'revert after renaming branch' '\n>>\n>> +test_expect_success 'revert on stat-dirty working tree' '\n>\n> ITYM s/revert/cherry-pick/\n\nGood eyes.  Yes, I do.\n"},{"id":"154903","messageId":"20101031222644.GA31257@arf.padd.com","threadId":"25602","inReplyTo":"20101031195933.GA21240@burratino","subject":"Re: [PATCH] cherry-pick/revert: transparently refresh index","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2010-10-31T22:26:44Z","receivedAt":"2010-10-31T22:26:44Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"jrnieder@gmail.com wrote on Sun, 31 Oct 2010 14:59 -0500:\n> A stat-dirty index is not a detail that ought to concern the operator\n> of porcelain such as \"git cherry-pick\".\n> \n> Without this change, a cherry-pick after copying a worktree with rsync\n> errors out with a misleading message.\n> \n> \t$ git cherry-pick build/top\n> \terror: Your local changes to 'file.h' would be overwritten by merge.  Aborting.\n> \tPlease, commit your changes or stash them before you can merge.\n> \n> Noticed-by: Pete Wyckoff <pw@padd.com>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n\nThanks, this works well.  I tested it and am happy with the\nchange.  It is needed for correctness.\n\nSince I know that I just copied the repo, I'd prefer not to\nmake people wait to refresh the index.  A new flag to\nupdate-index improves performance by avoiding the initial\nre-read of all files in the repository.  Patch follows in\nnext mail.\n\n\t\t-- Pete\n"},{"id":"154904","messageId":"20101031222805.GB31257@arf.padd.com","threadId":"25602","inReplyTo":"20101031222644.GA31257@arf.padd.com","subject":"[PATCH] teach update-index --refresh about --data-unchanged","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2010-10-31T22:28:05Z","receivedAt":"2010-10-31T22:28:05Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"When a repository has been copied with rsync, or cloned using\na volume manager, the index can be incorrect even though the\ndata is unchanged.  This new flag tells update-index --refresh\nthat it is not necessary to reread the data contents.  Without\nthis flag, everything works, but it is much slower due to the\nneed to read all files.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n Documentation/git-update-index.txt |    9 +++++++++\n builtin/update-index.c             |    6 +++++-\n cache.h                            |    9 ++++++---\n read-cache.c                       |   16 ++++++++++------\n 4 files changed, 30 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt\nindex 765d4b3..69aaaee 100644\n--- a/Documentation/git-update-index.txt\n+++ b/Documentation/git-update-index.txt\n@@ -14,6 +14,7 @@ SYNOPSIS\n \t     [--refresh] [-q] [--unmerged] [--ignore-missing]\n \t     [--cacheinfo <mode> <object> <file>]\\*\n \t     [--chmod=(+|-)x]\n+\t     [--data-unchanged]\n \t     [--assume-unchanged | --no-assume-unchanged]\n \t     [--skip-worktree | --no-skip-worktree]\n \t     [--ignore-submodules]\n@@ -65,6 +66,14 @@ OPTIONS\n \tbehavior is to error out.  This option makes 'git update-index'\n         continue anyway.\n \n+--data-unchanged::\n+\tWhen refreshing the cache, do not re-read all data\n+\tfiles to verify that they are unchanged.  This flag\n+\tattests that even though the index may be invalid, file content\n+\thas not been changed.  This situation can happen when\n+\ta repository is copied with `rsync` or with a volume manager\n+\tclone command.\n+\n --ignore-missing::\n \tIgnores missing files during a --refresh\n \ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 3ab214d..dc609cc 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -398,7 +398,7 @@ static void read_index_info(int line_termination)\n }\n \n static const char update_index_usage[] =\n-\"git update-index [-q] [--add] [--replace] [--remove] [--unmerged] [--refresh] [--really-refresh] [--cacheinfo] [--chmod=(+|-)x] [--assume-unchanged] [--skip-worktree|--no-skip-worktree] [--info-only] [--force-remove] [--stdin] [--index-info] [--unresolve] [--again | -g] [--ignore-missing] [-z] [--verbose] [--] <file>...\";\n+\"git update-index [-q] [--add] [--replace] [--remove] [--unmerged] [--data-unchanged] [--refresh] [--really-refresh] [--cacheinfo] [--chmod=(+|-)x] [--assume-unchanged] [--skip-worktree|--no-skip-worktree] [--info-only] [--force-remove] [--stdin] [--index-info] [--unresolve] [--again | -g] [--ignore-missing] [-z] [--verbose] [--] <file>...\";\n \n static unsigned char head_sha1[20];\n static unsigned char merge_head_sha1[20];\n@@ -635,6 +635,10 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\t\t\trefresh_flags |= REFRESH_UNMERGED;\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(path, \"--data-unchanged\")) {\n+\t\t\t\trefresh_flags |= REFRESH_DATA_UNCHANGED;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(path, \"--refresh\")) {\n \t\t\t\tsetup_work_tree();\n \t\t\t\thas_errors |= refresh_cache(refresh_flags);\ndiff --git a/cache.h b/cache.h\nindex 1e690d1..b2e692c 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -485,11 +485,13 @@ extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);\n extern int index_name_is_other(const struct index_state *, const char *, int);\n \n /* do stat comparison even if CE_VALID is true */\n-#define CE_MATCH_IGNORE_VALID\t\t01\n+#define CE_MATCH_IGNORE_VALID\t\t0x1\n /* do not check the contents but report dirty on racily-clean entries */\n-#define CE_MATCH_RACY_IS_DIRTY\t\t02\n+#define CE_MATCH_RACY_IS_DIRTY\t\t0x2\n /* do stat comparison even if CE_SKIP_WORKTREE is true */\n-#define CE_MATCH_IGNORE_SKIP_WORKTREE\t04\n+#define CE_MATCH_IGNORE_SKIP_WORKTREE\t0x4\n+/* trust that the contents of files have not been modified */\n+#define CE_MATCH_DATA_UNCHANGED\t\t0x8\n extern int ie_match_stat(const struct index_state *, struct cache_entry *, struct stat *, unsigned int);\n extern int ie_modified(const struct index_state *, struct cache_entry *, struct stat *, unsigned int);\n \n@@ -504,6 +506,7 @@ extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);\n #define REFRESH_IGNORE_MISSING\t0x0008\t/* ignore non-existent */\n #define REFRESH_IGNORE_SUBMODULES\t0x0010\t/* ignore submodules */\n #define REFRESH_IN_PORCELAIN\t0x0020\t/* user friendly output, not \"needs update\" */\n+#define REFRESH_DATA_UNCHANGED\t0x0040\t/* no need to read all files, trust unmodified */\n extern int refresh_index(struct index_state *, unsigned int flags, const char **pathspec, char *seen, char *header_msg);\n \n struct lock_file {\ndiff --git a/read-cache.c b/read-cache.c\nindex 1f42473..26d5d5f 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -137,12 +137,14 @@ static int ce_compare_gitlink(struct cache_entry *ce)\n \treturn hashcmp(sha1, ce->sha1);\n }\n \n-static int ce_modified_check_fs(struct cache_entry *ce, struct stat *st)\n+static int ce_modified_check_fs(struct cache_entry *ce, struct stat *st,\n+\t\t\t\tint options)\n {\n \tswitch (st->st_mode & S_IFMT) {\n \tcase S_IFREG:\n-\t\tif (ce_compare_data(ce, st))\n-\t\t\treturn DATA_CHANGED;\n+\t\tif (!(options & CE_MATCH_DATA_UNCHANGED))\n+\t\t\tif (ce_compare_data(ce, st))\n+\t\t\t\treturn DATA_CHANGED;\n \t\tbreak;\n \tcase S_IFLNK:\n \t\tif (ce_compare_link(ce, xsize_t(st->st_size)))\n@@ -304,7 +306,7 @@ int ie_match_stat(const struct index_state *istate,\n \t\tif (assume_racy_is_modified)\n \t\t\tchanged |= DATA_CHANGED;\n \t\telse\n-\t\t\tchanged |= ce_modified_check_fs(ce, st);\n+\t\t\tchanged |= ce_modified_check_fs(ce, st, 0);\n \t}\n \n \treturn changed;\n@@ -343,7 +345,7 @@ int ie_modified(const struct index_state *istate,\n \t    (S_ISGITLINK(ce->ce_mode) || ce->ce_size != 0))\n \t\treturn changed;\n \n-\tchanged_fs = ce_modified_check_fs(ce, st);\n+\tchanged_fs = ce_modified_check_fs(ce, st, options);\n \tif (changed_fs)\n \t\treturn changed | changed_fs;\n \treturn 0;\n@@ -1108,6 +1110,8 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p\n \n \tneeds_update_fmt = (in_porcelain ? \"M\\t%s\\n\" : \"%s: needs update\\n\");\n \tneeds_merge_fmt = (in_porcelain ? \"U\\t%s\\n\" : \"%s: needs merge\\n\");\n+\tif (flags & REFRESH_DATA_UNCHANGED)\n+\t    options |= CE_MATCH_DATA_UNCHANGED;\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce, *new;\n \t\tint cache_errno = 0;\n@@ -1481,7 +1485,7 @@ static void ce_smudge_racily_clean_entry(struct cache_entry *ce)\n \t\treturn;\n \tif (ce_match_stat_basic(ce, &st))\n \t\treturn;\n-\tif (ce_modified_check_fs(ce, &st)) {\n+\tif (ce_modified_check_fs(ce, &st, 0)) {\n \t\t/* This is \"racily clean\"; smudge it.  Note that this\n \t\t * is a tricky code.  At first glance, it may appear\n \t\t * that it can break with this sequence:\n-- \n1.7.2.3\n"},{"id":"154918","messageId":"201011010909.15198.j6t@kdbg.org","threadId":"25602","inReplyTo":"20101031195933.GA21240@burratino","subject":"Re: [PATCH] cherry-pick/revert: transparently refresh index","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-11-01T08:09:15Z","receivedAt":"2010-11-01T08:09:15Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Sonntag, 31. Oktober 2010, Jonathan Nieder wrote:\n> +test_expect_success 'revert on stat-dirty working tree' '\n> +\tgit clone . repo &&\n> +\t(\n> +\t\tcd repo &&\n> +\t\tgit checkout initial\n> +\t) &&\n> +\tcp -R repo copy &&\n> +\t(\n> +\t\tcd copy &&\n> +\t\tgit cherry-pick added\n> +\t)\n\nOn Windows, this doesn't test what it should test because we do not look at \nthe inode number (currently). Please use test-chmtime to change stat \ninformation.\n\n-- Hannes\n"},{"id":"154920","messageId":"AANLkTimqpwgvHS7+Q98RPrtD+j7gN7T3-ZrJDCLBq0sF@mail.gmail.com","threadId":"25602","inReplyTo":"20101031195933.GA21240@burratino","subject":"Re: [PATCH] cherry-pick/revert: transparently refresh index","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-11-01T08:44:43Z","receivedAt":"2010-11-01T08:44:43Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"> +static void read_and_refresh_cache(const char *me)\n> +{\n> +       static struct lock_file index_lock;\n> +       int index_fd = hold_locked_index(&index_lock, 0);\n> +       if (read_index_preload(&the_index, NULL) < 0)\n> +               die(\"git %s: failed to read the index\", me);\n> +       refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL, NULL);\n\nCan we refresh only index entries that are cherry-picked/reverted?\nFull refresh can be expensive on large repos while these operations\ndon't usually touch the whole repo.\n\nI'm thinking of adding ce_really_uptodate() and converting most of\nce_uptodate() call sites  to the new one.\n\ndiff --git a/cache.h b/cache.h\nindex 123dd4b..81dc5cf 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -240,6 +240,7 @@ static inline size_t ce_namelen(const struct\ncache_entry *ce)\n \t\t\t    ondisk_cache_entry_size(ce_namelen(ce)))\n #define ce_stage(ce) ((CE_STAGEMASK & (ce)->ce_flags) >> CE_STAGESHIFT)\n #define ce_uptodate(ce) ((ce)->ce_flags & CE_UPTODATE)\n+#define ce_really_uptodate(ce) (ce_uptodate(ce) ||\n(refresh_cache_entry(ce), ce_uptodate(ce)))\n #define ce_skip_worktree(ce) ((ce)->ce_flags & CE_SKIP_WORKTREE)\n #define ce_mark_uptodate(ce) ((ce)->ce_flags |= CE_UPTODATE)\n\n@@ -512,6 +513,7 @@ extern void fill_stat_cache_info(struct\ncache_entry *ce, struct stat *st);\n #define REFRESH_IGNORE_SUBMODULES\t0x0010\t/* ignore submodules */\n #define REFRESH_IN_PORCELAIN\t0x0020\t/* user friendly output, not\n\"needs update\" */\n extern int refresh_index(struct index_state *, unsigned int flags,\nconst char **pathspec, char *seen, char *header_msg);\n+extern struct cache_entry *refresh_cache_entry(struct cache_entry\n*ce, int really);\n\n struct lock_file {\n \tstruct lock_file *next;\ndiff --git a/read-cache.c b/read-cache.c\nindex 1f42473..76525a9 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -1156,7 +1156,7 @@ int refresh_index(struct index_state *istate,\nunsigned int flags, const char **p\n \treturn has_errors;\n }\n\n-static struct cache_entry *refresh_cache_entry(struct cache_entry\n*ce, int really)\n+struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really)\n {\n \treturn refresh_cache_ent(&the_index, ce, really, NULL);\n }\n-- \nDuy\n"},{"id":"155076","messageId":"7v4obyxqkb.fsf@alter.siamese.dyndns.org","threadId":"25602","inReplyTo":"201011010909.15198.j6t@kdbg.org","subject":"Re: [PATCH] cherry-pick/revert: transparently refresh index","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-11-03T17:30:44Z","receivedAt":"2010-11-03T17:30:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> On Windows, this doesn't test what it should test because we do not look at \n> the inode number (currently). Please use test-chmtime to change stat \n> information.\n\nLike this, perhaps?\n\ndiff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh\nindex b210188..a5b963a 100755\n--- a/t/t3501-revert-cherry-pick.sh\n+++ b/t/t3501-revert-cherry-pick.sh\n@@ -81,15 +81,12 @@ test_expect_success 'revert after renaming branch' '\n \n '\n \n-test_expect_success 'revert on stat-dirty working tree' '\n-\tgit clone . repo &&\n-\t(\n-\t\tcd repo &&\n-\t\tgit checkout initial\n-\t) &&\n-\tcp -R repo copy &&\n+test_expect_success 'cherry-pick on stat-dirty working tree' '\n+\tgit clone . copy\n \t(\n \t\tcd copy &&\n+\t\tgit checkout initial &&\n+\t\ttest-chmtime +40 oops &&\n \t\tgit cherry-pick added\n \t)\n '\n"},{"id":"155077","messageId":"7vzktqwbob.fsf@alter.siamese.dyndns.org","threadId":"25602","inReplyTo":"20101031222805.GB31257@arf.padd.com","subject":"Re: [PATCH] teach update-index --refresh about --data-unchanged","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-11-03T17:37:40Z","receivedAt":"2010-11-03T17:37:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pete Wyckoff <pw@padd.com> writes:\n\n> When a repository has been copied with rsync, or cloned using\n> a volume manager, the index can be incorrect even though the\n> data is unchanged.  This new flag tells update-index --refresh\n> that it is not necessary to reread the data contents.\n\nI know our traditional attitude towards the plumbing commands have been\n\"give them long enough rope and let users hang themselves\", but this\nparticular rope feels a bit too long for my taste.\n"},{"id":"155079","messageId":"20101103183621.GA14019@burratino","threadId":"25602","inReplyTo":"7vzktqwbob.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] teach update-index --refresh about --data-unchanged","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-11-03T18:36:21Z","receivedAt":"2010-11-03T18:36:21Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"On Wed, Nov 03, 2010 at 10:37:40AM -0700, Junio C Hamano wrote:\n> Pete Wyckoff <pw@padd.com> writes:\n\n>> When a repository has been copied with rsync, or cloned using\n>> a volume manager, the index can be incorrect even though the\n>> data is unchanged.  This new flag tells update-index --refresh\n>> that it is not necessary to reread the data contents.\n>\n> I know our traditional attitude towards the plumbing commands have been\n> \"give them long enough rope and let users hang themselves\", but this\n> particular rope feels a bit too long for my taste.\n\nPete, I think you mentioned the possibility of a special-case tool for\ncontrib/ that just updates the inode, device number, and ctime fields?\nThat sounds a little less worrying to use, as plumbing.\n"},{"id":"155084","messageId":"201011032133.23448.j6t@kdbg.org","threadId":"25602","inReplyTo":"7v4obyxqkb.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] cherry-pick/revert: transparently refresh index","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-11-03T20:33:23Z","receivedAt":"2010-11-03T20:33:23Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Mittwoch, 3. November 2010, Junio C Hamano wrote:\n> Johannes Sixt <j6t@kdbg.org> writes:\n> > On Windows, this doesn't test what it should test because we do not look\n> > at the inode number (currently). Please use test-chmtime to change stat\n> > information.\n>\n> Like this, perhaps?\n>\n> diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh\n> index b210188..a5b963a 100755\n> --- a/t/t3501-revert-cherry-pick.sh\n> +++ b/t/t3501-revert-cherry-pick.sh\n> @@ -81,15 +81,12 @@ test_expect_success 'revert after renaming branch' '\n>\n>  '\n>\n> -test_expect_success 'revert on stat-dirty working tree' '\n> -\tgit clone . repo &&\n> -\t(\n> -\t\tcd repo &&\n> -\t\tgit checkout initial\n> -\t) &&\n> -\tcp -R repo copy &&\n> +test_expect_success 'cherry-pick on stat-dirty working tree' '\n> +\tgit clone . copy\n>  \t(\n>  \t\tcd copy &&\n> +\t\tgit checkout initial &&\n> +\t\ttest-chmtime +40 oops &&\n>  \t\tgit cherry-pick added\n>  \t)\n>  '\n\nYes, makes sense.\n\n-- Hannes\n"},{"id":"155088","messageId":"20101103220243.GA6777@arf.padd.com","threadId":"25602","inReplyTo":"20101103183621.GA14019@burratino","subject":"Re: [PATCH] teach update-index --refresh about --data-unchanged","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2010-11-03T22:02:43Z","receivedAt":"2010-11-03T22:02:43Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"jrnieder@gmail.com wrote on Wed, 03 Nov 2010 13:36 -0500:\n> On Wed, Nov 03, 2010 at 10:37:40AM -0700, Junio C Hamano wrote:\n> > Pete Wyckoff <pw@padd.com> writes:\n> \n> >> When a repository has been copied with rsync, or cloned using\n> >> a volume manager, the index can be incorrect even though the\n> >> data is unchanged.  This new flag tells update-index --refresh\n> >> that it is not necessary to reread the data contents.\n> >\n> > I know our traditional attitude towards the plumbing commands have been\n> > \"give them long enough rope and let users hang themselves\", but this\n> > particular rope feels a bit too long for my taste.\n> \n> Pete, I think you mentioned the possibility of a special-case tool for\n> contrib/ that just updates the inode, device number, and ctime fields?\n> That sounds a little less worrying to use, as plumbing.\n\nYes, I'd been discussing with Jonathan offlist that I too agree\nthis is a bit bizarre for general use.  Especially when thinking\nabout how to explain the new flag in the manpage, and how\ninteractions with other command-line options should work.\n\nI wrote a short C program to use existing functions from cache.h\nto read and write the index, updating the entries by hand.  Once\nI figure out how to build it nicely, I'll submit for contrib/.  I\nhaven't figured out how to include the useful bits of the\ntop-level Makefile (like SSL setting, which SHA1, -lpthread,\netc.).\n\n\t\t-- Pete\n"},{"id":"155856","messageId":"20101114165819.GA8714@arf.padd.com","threadId":"25602","inReplyTo":"20101103220243.GA6777@arf.padd.com","subject":"Re: [PATCH] teach update-index --refresh about --data-unchanged","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2010-11-14T16:58:19Z","receivedAt":"2010-11-14T16:58:19Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"pw@padd.com wrote on Wed, 03 Nov 2010 18:02 -0400:\n> jrnieder@gmail.com wrote on Wed, 03 Nov 2010 13:36 -0500:\n> > On Wed, Nov 03, 2010 at 10:37:40AM -0700, Junio C Hamano wrote:\n> > > Pete Wyckoff <pw@padd.com> writes:\n> > \n> > >> When a repository has been copied with rsync, or cloned using\n> > >> a volume manager, the index can be incorrect even though the\n> > >> data is unchanged.  This new flag tells update-index --refresh\n> > >> that it is not necessary to reread the data contents.\n> > >\n> > > I know our traditional attitude towards the plumbing commands have been\n> > > \"give them long enough rope and let users hang themselves\", but this\n> > > particular rope feels a bit too long for my taste.\n> > \n> > Pete, I think you mentioned the possibility of a special-case tool for\n> > contrib/ that just updates the inode, device number, and ctime fields?\n> > That sounds a little less worrying to use, as plumbing.\n> \n> Yes, I'd been discussing with Jonathan offlist that I too agree\n> this is a bit bizarre for general use.  Especially when thinking\n> about how to explain the new flag in the manpage, and how\n> interactions with other command-line options should work.\n> \n> I wrote a short C program to use existing functions from cache.h\n> to read and write the index, updating the entries by hand.  Once\n> I figure out how to build it nicely, I'll submit for contrib/.  I\n> haven't figured out how to include the useful bits of the\n> top-level Makefile (like SSL setting, which SHA1, -lpthread,\n> etc.).\n\nTurns out this was dead simple with dulwich, a python interface\nto git internals:  http://samba.org/~jelmer/dulwich .  I got rid\nof the C version.\n\nThe script uses dulwich to generate a list of index entries,\nstats each file and updates the entries, then writes it back\nout.  I won't submit it to contrib, since it is so trivial and\nbecause it depends on dulwich.\n\n\t\t-- Pete\n"},{"id":"155859","messageId":"20101114173454.GC26459@burratino","threadId":"25602","inReplyTo":"20101114165819.GA8714@arf.padd.com","subject":"Re: [PATCH] teach update-index --refresh about --data-unchanged","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-11-14T17:34:54Z","receivedAt":"2010-11-14T17:34:54Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Pete Wyckoff wrote:\n\n> The script uses dulwich to generate a list of index entries,\n> stats each file and updates the entries, then writes it back\n> out.  I won't submit it to contrib, since it is so trivial and\n> because it depends on dulwich.\n\nMaybe we can add Dulwich to contrib? :)\n"}]}