Re: [PATCH v2 1/2] mergetool: don't require a work tree for --tool-help
On Fri, Oct 10, 2014 at 10:01:57AM +0100, Charles Bailey wrote: On 10 Oct 2014, at 09:51, David Aguilar dav...@gmail.com wrote: Changes since v1: NONGIT_OK=Yes was added to make it actually work outside of a git repo. Does this actually work? The reason that I haven't got around to resending my re-roll is that I found that I needed changes to git-sh-setup.sh because doing NONGIT_OK and then require_work_tree didn't correctly set GIT_DIR when it wasn't already explicitly set in the environment. (I believe the rest of mergetool relies on it.) Perhaps I misunderstood, though. Thanks for the heads-up. I tested mergetool and it seems fine but indeed there's an `if test -e $GIT_DIR/MERGE_RR` in there that is surely not working as intended. One solution would be to move the work done in the test -z $NONGIT_OK block in git-sh-setup into a function e.g. git_dir_init () so that we can defer the GIT_DIR initialization until after require_work_tree has been called. -- David -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/2] mergetool: don't require a work tree for --tool-help
On 11 Oct 2014, at 09:29, David Aguilar dav...@gmail.com wrote: Thanks for the heads-up. I tested mergetool and it seems fine but indeed there's an `if test -e $GIT_DIR/MERGE_RR` in there that is surely not working as intended. One solution would be to move the work done in the test -z $NONGIT_OK block in git-sh-setup into a function e.g. git_dir_init () so that we can defer the GIT_DIR initialization until after require_work_tree has been called. I believe I had a very similar idea but the vast number of things that would potentially be affected by changing git-sh-setup.sh made me put things on hold in case I had any other ideas. I haven't so I think this is probably the best approach.-- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 2/3] mergetool: don't require a work tree for --tool-help
From: Charles Bailey cbaile...@bloomberg.net Signed-off-by: Charles Bailey cbaile...@bloomberg.net Signed-off-by: David Aguilar dav...@gmail.com --- Changes since v2: This now uses the new git_dir_init function. git-mergetool.sh | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git-mergetool.sh b/git-mergetool.sh index 96a61ba..cddb533 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -10,11 +10,11 @@ USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [file to merge] ...' SUBDIRECTORY_OK=Yes +NONGIT_OK=Yes OPTIONS_SPEC= TOOL_MODE=merge . git-sh-setup . git-mergetool--lib -require_work_tree # Returns true if the mode reflects a symlink is_symlink () { @@ -378,6 +378,9 @@ prompt_after_failed_merge () { done } +require_work_tree +git_dir_init + if test -z $merge_tool then # Check if a merge tool has been configured -- 2.1.2.378.g89c0b73 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 1/3] git-sh-setup: move GIT_DIR initialization into a function
Signed-off-by: David Aguilar dav...@gmail.com --- This is a new patch since the last round, prep for 2/3 git-sh-setup.sh | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/git-sh-setup.sh b/git-sh-setup.sh index 9447980..d968760 100644 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -330,8 +330,7 @@ esac # Make sure we are in a valid repository of a vintage we understand, # if we require to be in a git repository. -if test -z $NONGIT_OK -then +git_dir_init () { GIT_DIR=$(git rev-parse --git-dir) || exit if [ -z $SUBDIRECTORY_OK ] then @@ -346,6 +345,11 @@ then exit 1 } : ${GIT_OBJECT_DIRECTORY=$GIT_DIR/objects} +} + +if test -z $NONGIT_OK +then + git_dir_init fi peel_committish () { -- 2.1.2.378.g89c0b73 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 3/3] difftool: don't assume that default sh is sane
From: Charles Bailey cbaile...@bloomberg.net git-difftool used to create a command list script containing $( ... ) and explicitly calls sh -c with this list. Instead, allow mergetool --tool-help to take a mode parameter and call mergetool directly to invoke the show_tool_help function. This mode parameter is intented for use solely by difftool. Signed-off-by: Charles Bailey cbaile...@bloomberg.net Helped-by: John Keeping j...@keeping.me.uk Signed-off-by: David Aguilar dav...@gmail.com --- No changes since v2. git-difftool.perl | 6 +- git-mergetool.sh | 4 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/git-difftool.perl b/git-difftool.perl index 18ca61e..598fcc2 100755 --- a/git-difftool.perl +++ b/git-difftool.perl @@ -47,13 +47,9 @@ sub find_worktree sub print_tool_help { - my $cmd = 'TOOL_MODE=diff'; - $cmd .= ' . $(git --exec-path)/git-mergetool--lib'; - $cmd .= ' show_tool_help'; - # See the comment at the bottom of file_diff() for the reason behind # using system() followed by exit() instead of exec(). - my $rc = system('sh', '-c', $cmd); + my $rc = system(qw(git mergetool --tool-help=diff)); exit($rc | ($rc 8)); } diff --git a/git-mergetool.sh b/git-mergetool.sh index cddb533..10782b8 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -327,6 +327,10 @@ guessed_merge_tool=false while test $# != 0 do case $1 in + --tool-help=*) + TOOL_MODE=${1#--tool-help=} + show_tool_help + ;; --tool-help) show_tool_help ;; -- 2.1.2.378.g89c0b73 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [msysGit] [PATCH 07/14] Fix BASIC_LDFLAGS and COMPAT_CFLAGS for 64bit MinGW-w64
Hi Ray, On Fri, 10 Oct 2014, Ray Donnelly wrote: what's the difference between https://github.com/msysgit/git and https://github.com/git-for-windows/git ? I noticed that your fork is forked from msysgit, not git-for-windows? I am glad you asked! Git for Windows was developed using the development environment called msysGit ever since 2007. Unfortunately the name caused a *real* lot of confusion, not only because some people wondered what the heck MSys is, but those who did not wonder mistook it for a *different* version of Git for Windows. Apart from the name, msysGit also has the shortcoming of abusing Git to deploy binaries. In other words, msysGit itself is a Git-managed project that delivers the complete development environment. Upgrading individual components is unnecessarily hard, but msysGit's way was necessary because there was no nice package manager for MinGW/MSys yet. Things have changed in the meantime, and pushed forward by Thomas Braun and Sebastian Schuberth, we now have a light-weight Git for Windows SDK – which is essentially a standard MinGW/MSys system managed through the package manager mingw-get. The only two add-ons we have is a nicer installer (that Sebastian offered to MinGW but they declined) and the addition of our own mingw-get'able packages (such as openssl, libpcre, and git itself). Needless to say, I am a big fan of that new strategy. This is why we decided to just phase out the name msysGit (as well as the GitHub org of the same name) and work on Git for Windows (with the corresponding GitHub org, and using the name Git for Windows for the installer aimed at end-users and Git for Windows SDK for the development environment targeting Git for Windows developers). I also added this writeup to the FAQ on the msysGit wiki: https://github.com/msysgit/msysgit/wiki/Relationship-to-Git-for-Windows Ciao, Johannes
Re: [PATCH v4 0/3] Make 'git help everyday' work
From: Junio C Hamano gits...@pobox.com Thanks. Looked alright from a cursory read; I tweaked s/10/-10/ where you gave examples of limiting output from git log before queuing. That was my mis-reading. I'd even noticed that it looked 'different' but just didn't see the leading '-' when checking the man page. -- Thanks Philip -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] receive-pack: plug minor memory leak in unpack()
The argv_array used in unpack() is never freed. Instead of adding explicit calls to argv_array_clear() use the args member of struct child_process and let run_command() and friends clean up for us. Signed-off-by: Rene Scharfe l@web.de --- builtin/receive-pack.c | 18 -- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index a51846c..443dd37 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -1220,7 +1220,6 @@ static const char *pack_lockfile; static const char *unpack(int err_fd, struct shallow_info *si) { struct pack_header hdr; - struct argv_array av = ARGV_ARRAY_INIT; const char *hdr_err; int status; char hdr_arg[38]; @@ -1243,16 +1242,16 @@ static const char *unpack(int err_fd, struct shallow_info *si) if (si-nr_ours || si-nr_theirs) { alt_shallow_file = setup_temporary_shallow(si-shallow); - argv_array_pushl(av, --shallow-file, alt_shallow_file, NULL); + argv_array_push(child.args, --shallow-file); + argv_array_push(child.args, alt_shallow_file); } if (ntohl(hdr.hdr_entries) unpack_limit) { - argv_array_pushl(av, unpack-objects, hdr_arg, NULL); + argv_array_pushl(child.args, unpack-objects, hdr_arg, NULL); if (quiet) - argv_array_push(av, -q); + argv_array_push(child.args, -q); if (fsck_objects) - argv_array_push(av, --strict); - child.argv = av.argv; + argv_array_push(child.args, --strict); child.no_stdout = 1; child.err = err_fd; child.git_cmd = 1; @@ -1267,13 +1266,12 @@ static const char *unpack(int err_fd, struct shallow_info *si) if (gethostname(keep_arg + s, sizeof(keep_arg) - s)) strcpy(keep_arg + s, localhost); - argv_array_pushl(av, index-pack, + argv_array_pushl(child.args, index-pack, --stdin, hdr_arg, keep_arg, NULL); if (fsck_objects) - argv_array_push(av, --strict); + argv_array_push(child.args, --strict); if (fix_thin) - argv_array_push(av, --fix-thin); - child.argv = av.argv; + argv_array_push(child.args, --fix-thin); child.out = -1; child.err = err_fd; child.git_cmd = 1; -- 2.1.2 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [msysGit] [PATCH 07/14] Fix BASIC_LDFLAGS and COMPAT_CFLAGS for 64bit MinGW-w64
Hi, On Fri, 10 Oct 2014, Johannes Schindelin wrote: On Fri, 10 Oct 2014, Johannes Schindelin wrote: With this [mingw-w64] compiler, and the 'w64' branch from https://github.com/dscho/git – intended to be merged into https://github.com/git-for-windows/git – the following command-line produces 64-bit Git: PATH=/path/to/unpacked/mingw-w64/mingw64/bin/:$PATH \ make \ CROSS_COMPILE=x86_64-w64-mingw32- CC='$(CROSS_COMPILE)gcc' \ AR=ar RC=windres \ NO_ICONV=1 NO_OPENSSL=1 NO_CURL=1 NEEDS_LIBICONV= USE_LIBPCRE= The test suite passes so far (still running, at the time of writing it is going through t3404). [...] So I fear we have still a ways to go before Git works as a 64-bit Windows binary... It seems to be not *all* that bad: only t3900, t3901, t4041, t4205, t4210, t5100, t6006 and t7102 display test failures. Ciao, Dscho
[PATCH 1/2] fix compilation with --disable-pthreads
Signed-off-by: Etienne Buira etienne.bu...@gmail.com --- builtin/index-pack.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/builtin/index-pack.c b/builtin/index-pack.c index eebf1a8..0f88f4b 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -185,6 +185,9 @@ static void cleanup_thread(void) #define deepest_delta_lock() #define deepest_delta_unlock() +#define type_cas_lock() +#define type_cas_unlock() + #endif -- 1.8.5.5 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] Remove spurious 'no threads support' warnings
Threads count being defaulted to 0 (autodetect), and --disable-pthreads build checking that thread count==1, there were spurious warnings about threads being ignored, despite not specified on command line/conf. Fixes tests 5521 and 5526 that were broken in --disable-pthreads builds because of those warnings. Signed-off-by: Etienne Buira etienne.bu...@gmail.com --- builtin/pack-objects.c | 2 +- thread-utils.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index b59f5d8..7b51453 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -51,7 +51,7 @@ static int progress = 1; static int window = 10; static unsigned long pack_size_limit; static int depth = 50; -static int delta_search_threads; +static int delta_search_threads = THREAD_COMPAT_DEFAULT_THREAD_NBR; static int pack_to_stdout; static int num_preferred_base; static struct progress *progress_state; diff --git a/thread-utils.h b/thread-utils.h index 6fb98c3..4f5e802 100644 --- a/thread-utils.h +++ b/thread-utils.h @@ -7,5 +7,8 @@ extern int online_cpus(void); extern int init_recursive_mutex(pthread_mutex_t*); +#define THREAD_COMPAT_DEFAULT_THREAD_NBR 0 +#else +#define THREAD_COMPAT_DEFAULT_THREAD_NBR 1 #endif #endif /* THREAD_COMPAT_H */ -- 1.8.5.5 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Handle atexit list internaly fo unthreaded builds
Replace atexit()s calls with cmd_atexit that is atexit() on threaded builds, but handles the callbacks list internally for unthreaded builds. This is needed because on unthreaded builds, asyncs inherits parent's atexit() list, that gets run as soon as the async exit()s (and again at the end of the parent process). That led to remove temporary and lock files too early. Fixes test 5537 (temporary shallow file vanished before unpack-objects could open it) Signed-off-by: Etienne Buira etienne.bu...@gmail.com --- builtin/clone.c | 7 +-- builtin/fetch.c | 2 +- builtin/gc.c| 2 +- diff.c | 2 +- lockfile.c | 2 +- pager.c | 2 +- read-cache.c| 2 +- run-command.c | 45 - shallow.c | 7 ++- trace.c | 2 +- 10 files changed, 54 insertions(+), 19 deletions(-) diff --git a/builtin/clone.c b/builtin/clone.c index bbd169c..2992ac0 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -390,7 +390,6 @@ static void clone_local(const char *src_repo, const char *dest_repo) static const char *junk_work_tree; static const char *junk_git_dir; -static pid_t junk_pid; static enum { JUNK_LEAVE_NONE, JUNK_LEAVE_REPO, @@ -417,8 +416,6 @@ static void remove_junk(void) break; } - if (getpid() != junk_pid) - return; if (junk_git_dir) { strbuf_addstr(sb, junk_git_dir); remove_dir_recursively(sb, 0); @@ -758,8 +755,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix) struct refspec *refspec; const char *fetch_pattern; - junk_pid = getpid(); - packet_trace_identity(clone); argc = parse_options(argc, argv, prefix, builtin_clone_options, builtin_clone_usage, 0); @@ -843,7 +838,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) set_git_work_tree(work_tree); } junk_git_dir = git_dir; - atexit(remove_junk); + cmd_atexit(remove_junk); sigchain_push_common(remove_junk_on_signal); if (safe_create_leading_directories_const(git_dir) 0) diff --git a/builtin/fetch.c b/builtin/fetch.c index 159fb7e..1e44d58 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1095,7 +1095,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv) } sigchain_push_common(unlock_pack_on_signal); - atexit(unlock_pack); + cmd_atexit(unlock_pack); refspec = parse_fetch_refspec(ref_nr, refs); exit_code = do_fetch(gtransport, refspec, ref_nr); free_refspec(ref_nr, refspec); diff --git a/builtin/gc.c b/builtin/gc.c index 8d219d8..cf2defa 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -254,7 +254,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid) pidfile = git_pathdup(gc.pid); sigchain_push_common(remove_pidfile_on_signal); - atexit(remove_pidfile); + cmd_atexit(remove_pidfile); return NULL; } diff --git a/diff.c b/diff.c index 867f034..9c6ef9a 100644 --- a/diff.c +++ b/diff.c @@ -2833,7 +2833,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name, } if (!remove_tempfile_installed) { - atexit(remove_tempfile); + cmd_atexit(remove_tempfile); sigchain_push_common(remove_tempfile_on_signal); remove_tempfile_installed = 1; } diff --git a/lockfile.c b/lockfile.c index 2564a7f..ad0d1e2 100644 --- a/lockfile.c +++ b/lockfile.c @@ -141,7 +141,7 @@ static int lock_file(struct lock_file *lk, const char *path, int flags) if (0 = lk-fd) { if (!lock_file_list) { sigchain_push_common(remove_lock_file_on_signal); - atexit(remove_lock_file); + cmd_atexit(remove_lock_file); } lk-owner = getpid(); if (!lk-on_list) { diff --git a/pager.c b/pager.c index 8b5cbc5..09ab2fa 100644 --- a/pager.c +++ b/pager.c @@ -102,7 +102,7 @@ void setup_pager(void) /* this makes sure that the parent terminates after the pager */ sigchain_push_common(wait_for_pager_signal); - atexit(wait_for_pager); + cmd_atexit(wait_for_pager); } int pager_in_use(void) diff --git a/read-cache.c b/read-cache.c index 6f0057f..8b10c92 100644 --- a/read-cache.c +++ b/read-cache.c @@ -2104,7 +2104,7 @@ static int write_shared_index(struct index_state *istate, return do_write_locked_index(istate, lock, flags); } if (!installed_handler) { - atexit(remove_temporary_sharedindex); + cmd_atexit(remove_temporary_sharedindex); sigchain_push_common(remove_temporary_sharedindex_on_signal); } move_cache_to_base_index(istate); diff --git a/run-command.c b/run-command.c
[PATCH] remote.c - Make remote definition require a url
Some options may be configured globally for a remote (e.g, tagopt). The presence of such options in a global config should not cause git remote or get fetch to believe that remote is configured for every repository. Change to require definition of remote.foo.url for the remote to be included in git fetch --all or git remote update. Signed-off-by: Mark Levedahl mleved...@gmail.com --- remote.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote.c b/remote.c index ce785f8..1b08924 100644 --- a/remote.c +++ b/remote.c @@ -761,7 +761,7 @@ int for_each_remote(each_remote_fn fn, void *priv) read_config(); for (i = 0; i remotes_nr !result; i++) { struct remote *r = remotes[i]; - if (!r) + if (!r || !r-url) continue; if (!r-fetch) r-fetch = parse_fetch_refspec(r-fetch_refspec_nr, -- 2.1.2.2.0.14 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] git-completion.bash - avoid excruciatingly slow ref completion on Cygwin
$git checkout tab was taking about 3.5 seconds to respond on one repository having four remotes with about 100 total refs (measured on Cygwin). All of the time was being claimed in git for-each-ref to do its work. This working directory was created using git-new-workdir, and thus .git/refs and .git/packed-refs are both symlinks. for-each-ref operates in a way that causes the .git/refs symlink to be resolved multiple times for each ref in the repository, and Cygwin is especially slow in such operations. Patching refs.c to avoid repeatedly dereferencing the symlink reduced execution time from about 3.5 seconds to about 1.1 seconds (but no improvement on Linux), while an alternate approach of replacing the ref-list expansion with a shell pipeline provides a larger improvement on Cygwin and also improves Linux. So, the shell pipeline approach is provided here. Relevant timing results using the same repository on both Linux and Cygwin: On Cygwin: $ time git for-each-ref --format=%(refname:short) refs real0m3.523s user0m0.436s sys 0m2.733s $ time (cd $GIT_DIR ; cat packed-refs ; find refs/ -type f) \ 2/dev/null | sed -ne 's@^.*refs/@refs/@p' | sort | uniq real0m0.503s user0m0.307s sys 0m0.139s On Linux (essentially the same hardware): $ time git for-each-ref --format=%(refname:short) refs real0m0.020s user0m0.006s sys 0m0.014s $ time (cd $GIT_DIR ; cat packed-refs ; find refs/ -type f) \ 2/dev/null | sed -ne 's@^.*refs/@refs/@p' | sort | uniq real0m0.012s user0m0.006s sys 0m0.005s So, this is a win even on Linux, but more importantly it makes use of tab completion tolerable on Cygwin when symlinks are involved. Signed-off-by: Mark Levedahl mleved...@gmail.com --- contrib/completion/git-completion.bash | 22 ++ 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 965778e..62d976e 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -319,8 +319,9 @@ __git_heads () { local dir=$(__gitdir) if [ -d $dir ]; then - git --git-dir=$dir for-each-ref --format='%(refname:short)' \ - refs/heads + (cd $dir ; cat packed-refs ; find refs/heads -type f) 2/dev/null | + sed -ne 's@^.*refs/heads/@@p' | + sort -u return fi } @@ -329,8 +330,9 @@ __git_tags () { local dir=$(__gitdir) if [ -d $dir ]; then - git --git-dir=$dir for-each-ref --format='%(refname:short)' \ - refs/tags + (cd $dir ; cat packed-refs ; find refs/tags -type f) 2/dev/null | + sed -ne 's@^.*refs/tags/@@p' | + sort -u return fi } @@ -348,17 +350,21 @@ __git_refs () format=refname refs=${cur%/*} track= + (cd $dir ; cat packed-refs ; find refs/ -type f) 2/dev/null | + sed -ne 's@^.*refs/@refs/@p' | + sort -u + return ;; *) for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do if [ -e $dir/$i ]; then echo $i; fi done - format=refname:short - refs=refs/tags refs/heads refs/remotes + (cd $dir ; cat packed-refs ; find refs/ -type f) 2/dev/null | + sed -rne 's@^.*refs/(heads|remotes|tags)/@@p' | + sort -u + return ;; esac - git --git-dir=$dir for-each-ref --format=%($format) \ - $refs if [ -n $track ]; then # employ the heuristic used by git checkout # Try to find a remote branch that matches the completion word -- 2.1.2.2.0.14 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] mergetool: add an option for writing to a temporary directory
Teach mergetool to write files in a temporary directory when 'mergetool.writeToTemp' is true. This is helpful for tools such as Eclipse which cannot cope with multiple copies of the same file in the worktree. Suggested-by: Charles Bailey char...@hashpling.org Signed-off-by: David Aguilar dav...@gmail.com --- This patch is dependent on my previous mergetool patches: use more conservative temporary... and the subsequent --tool-help series. Documentation/config.txt | 6 ++ git-mergetool.sh | 35 +++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 04a1e2f..be6cf35 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1768,6 +1768,12 @@ mergetool.keepTemporaries:: preserved, otherwise they will be removed after the tool has exited. Defaults to `false`. +mergetool.writeToTemp:: + Git writes temporary 'BASE', 'LOCAL', and 'REMOTE' versions of + conflicting files in the worktree by default. Git will attempt + to use a temporary directory for these files when set `true`. + Defaults to `false`. + mergetool.prompt:: Prompt before each invocation of the merge resolution program. diff --git a/git-mergetool.sh b/git-mergetool.sh index 10782b8..2b788c5 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -37,6 +37,19 @@ base_present () { test -n $base_mode } +mergetool_tmpdir_init () { + if test $(git config --bool mergetool.writeToTemp) != true + then + MERGETOOL_TMPDIR=. + return 0 + fi + if MERGETOOL_TMPDIR=$(mktemp -d -t git-mergetool-XX 2/dev/null) + then + return 0 + fi + die error: mktemp is needed when 'mergetool.writeToTemp' is true +} + cleanup_temp_files () { if test $1 = --save-backup then @@ -46,6 +59,10 @@ cleanup_temp_files () { else rm -f -- $LOCAL $REMOTE $BASE $BACKUP fi + if test $MERGETOOL_TMPDIR != . + then + rmdir $MERGETOOL_TMPDIR + fi } describe_file () { @@ -235,10 +252,20 @@ merge_file () { BASE=$MERGED ext= fi - BACKUP=./${BASE}_BACKUP_$$$ext - LOCAL=./${BASE}_LOCAL_$$$ext - REMOTE=./${BASE}_REMOTE_$$$ext - BASE=./${BASE}_BASE_$$$ext + + mergetool_tmpdir_init + + if test $MERGETOOL_TMPDIR != . + then + # If we're using a temporary directory then write to the + # top-level of that directory. + BASE=${BASE##*/} + fi + + BACKUP=$MERGETOOL_TMPDIR/${BASE}_BACKUP_$$$ext + LOCAL=$MERGETOOL_TMPDIR/${BASE}_LOCAL_$$$ext + REMOTE=$MERGETOOL_TMPDIR/${BASE}_REMOTE_$$$ext + BASE=$MERGETOOL_TMPDIR/${BASE}_BASE_$$$ext base_mode=$(git ls-files -u -- $MERGED | awk '{if ($3==1) print $1;}') local_mode=$(git ls-files -u -- $MERGED | awk '{if ($3==2) print $1;}') -- 2.1.2.379.gc4e1e0c -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/4] Documentation: move some AsciiDoc parameters into variables
Asciidoctor takes slightly different arguments from AsciiDoc in some cases. It has a different name for the HTML backend and the docbook backend produces DocBook 5, not DocBook 4.5. Also, Asciidoctor does not accept the -f option. Move these values into variables so that they can be overridden by users wishing to use Asciidoctor instead of Asciidoc. Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- Documentation/Makefile | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index cea0e7a..00c50bf 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -97,6 +97,9 @@ man7dir = $(mandir)/man7 ASCIIDOC = asciidoc ASCIIDOC_EXTRA = +ASCIIDOC_HTML = xhtml11 +ASCIIDOC_DOCBOOK = docbook +ASCIIDOC_CONF = -f asciidoc.conf MANPAGE_XSL = manpage-normal.xsl XMLTO = xmlto XMLTO_EXTRA = @@ -304,13 +307,13 @@ clean: $(MAN_HTML): %.html : %.txt asciidoc.conf $(QUIET_ASCIIDOC)$(RM) $@+ $@ \ - $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \ + $(ASCIIDOC) -b $(ASCIIDOC_HTML) -d manpage $(ASCIIDOC_CONF) \ $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $ \ mv $@+ $@ $(OBSOLETE_HTML): %.html : %.txto asciidoc.conf $(QUIET_ASCIIDOC)$(RM) $@+ $@ \ - $(ASCIIDOC) -b xhtml11 -f asciidoc.conf \ + $(ASCIIDOC) -b $(ASCIIDOC_HTML) $(ASCIIDOC_CONF) \ $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $ \ mv $@+ $@ @@ -323,13 +326,13 @@ manpage-base-url.xsl: manpage-base-url.xsl.in %.xml : %.txt asciidoc.conf $(QUIET_ASCIIDOC)$(RM) $@+ $@ \ - $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \ + $(ASCIIDOC) -b $(ASCIIDOC_DOCBOOK) -d manpage $(ASCIIDOC_CONF) \ $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $ \ mv $@+ $@ user-manual.xml: user-manual.txt user-manual.conf $(QUIET_ASCIIDOC)$(RM) $@+ $@ \ - $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b docbook -d article -o $@+ $ \ + $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b $(ASCIIDOC_DOCBOOK) -d article -o $@+ $ \ mv $@+ $@ technical/api-index.txt: technical/api-index-skel.txt \ @@ -338,7 +341,7 @@ technical/api-index.txt: technical/api-index-skel.txt \ technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../ $(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt asciidoc.conf - $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 -f asciidoc.conf \ + $(QUIET_ASCIIDOC)$(ASCIIDOC) -b $(ASCIIDOC_HTML) $(ASCIIDOC_CONF) \ $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) $*.txt XSLT = docbook.xsl @@ -386,14 +389,15 @@ howto-index.txt: howto-index.sh $(wildcard howto/*.txt) mv $@+ $@ $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt - $(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 $*.txt + $(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b $(ASCIIDOC_HTML) $*.txt WEBDOC_DEST = /pub/software/scm/git/docs howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../ $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt $(QUIET_ASCIIDOC)$(RM) $@+ $@ \ - sed -e '1,/^$$/d' $ | $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 - $@+ \ + sed -e '1,/^$$/d' $ | \ + $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b $(ASCIIDOC_HTML) - $@+ \ mv $@+ $@ install-webdoc : html -- 2.1.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/4] Documentation: fix mismatched delimiters in git-imap-send
The documentation for git-imap-send uses block delimiters with mismatched lengths, which Asciidoctor doesn't support. As a result, the page is misrendered. Adjust the delimiters so that they are of the same length. Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- Documentation/git-imap-send.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/git-imap-send.txt b/Documentation/git-imap-send.txt index 7d991d9..c7c0d21 100644 --- a/Documentation/git-imap-send.txt +++ b/Documentation/git-imap-send.txt @@ -97,7 +97,7 @@ Using direct mode: host = imap://imap.example.com user = bob pass = p4ssw0rd -.. +. Using direct mode with SSL: @@ -109,7 +109,7 @@ Using direct mode with SSL: pass = p4ssw0rd port = 123 sslverify = false -.. +. EXAMPLE -- 2.1.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/4] Documentation: adjust document title underlining
AsciiDoc specification states that in two-line titles, the title underline has to be the same length as the title text, plus or minus two characters. Asciidoctor, however, requires that this must be plus or minus one character. Adjust the underlines to be the same length as the title text to improve compatibility. Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- Documentation/git-prune-packed.txt | 2 +- Documentation/git-quiltimport.txt | 2 +- Documentation/git-stage.txt| 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/git-prune-packed.txt b/Documentation/git-prune-packed.txt index 6738055..9fed59a 100644 --- a/Documentation/git-prune-packed.txt +++ b/Documentation/git-prune-packed.txt @@ -1,5 +1,5 @@ git-prune-packed(1) -= +=== NAME diff --git a/Documentation/git-quiltimport.txt b/Documentation/git-quiltimport.txt index a356196..d64388c 100644 --- a/Documentation/git-quiltimport.txt +++ b/Documentation/git-quiltimport.txt @@ -1,5 +1,5 @@ git-quiltimport(1) - +== NAME diff --git a/Documentation/git-stage.txt b/Documentation/git-stage.txt index ba3fe0d..25bcda9 100644 --- a/Documentation/git-stage.txt +++ b/Documentation/git-stage.txt @@ -1,5 +1,5 @@ git-stage(1) -== + NAME -- 2.1.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/4] Documentation: implement linkgit macro for Asciidoctor
AsciiDoc uses a configuration file to implement macros like linkgit, while Asciidoctor uses Ruby extensions. Implement a Ruby extension that implements the linkgit macro for Asciidoctor in the same way that asciidoc.conf does for AsciiDoc. Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- Documentation/extensions.rb | 39 +++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/extensions.rb diff --git a/Documentation/extensions.rb b/Documentation/extensions.rb new file mode 100644 index 000..c33a50d --- /dev/null +++ b/Documentation/extensions.rb @@ -0,0 +1,39 @@ +require 'asciidoctor' +require 'asciidoctor/extensions' + +module Git + module Documentation +class LinkGitProcessor Asciidoctor::Extensions::InlineMacroProcessor + use_dsl + + named :chrome + + def process(parent, target, attrs) +if parent.document.basebackend? 'html' + generate_html(parent, target, attrs) +elsif parent.document.basebackend? 'docbook' + generate_docbook(parent, target, attrs) +end + end + + private + + def generate_html(parent, target, attrs) +section = attrs.has_key?(1) ? (#{attrs[1]}) : '' +prefix = parent.document.attr('git-relative-html-prefix') || '' +%(a href=#{prefix}#{target}.html#{target}#{section}/a\n) + end + + def generate_docbook(parent, target, attrs) +%(citerefentry +refentrytitle#{target}/refentrytitlemanvolnum#{attrs[1]}/manvolnum +/citerefentry +) + end +end + end +end + +Asciidoctor::Extensions.register do + inline_macro Git::Documentation::LinkGitProcessor, :linkgit +end -- 2.1.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/4] Allow building Git with Asciidoctor
This series is designed to implement the changes necessary to build Git using Asciidoctor instead of AsciiDoc. The first two patches are bug fixes. Asciidoctor is stricter about title underline lengths (± 1 character instead of 2) and requires matching delimiter lengths[0]. They're needed regardless of whether the other two patches are accepted because git-scm.com uses Asciidoctor to render the documentation, so we might as well render it correctly. Even with these patches, Asciidoctor warns about everyday.txt and user-manual.txt. I'm not sending patches for these right now because I've seen recent series including those and don't want to cause a merge conflict. The second two patches implement some basic support for building with Asciidoctor. The first of these moves some items into variables due to some differences between the AsciiDoc and Asciidoctor command lines. The user can then override these values when invoking make. The final patch adds support for the linkgit macro. Asciidoctor uses Ruby extensions to implement macro support, unlike AsciiDoc, which uses a configuration file. In order to build the documentation successfully, the patches from [1] are required. The current version of Asciidoctor uses the wrong elements in some cases and is lacking elements in others when generating manpage (refentry) output in DocBook format. The need for these patches is also the reason I didn't implement a configuration macro for Asciidoctor, as almost nobody will be able to use it at the moment. With these patches and the ones for Asciidoctor, it's possible to build the documentation with the following command line: make doc ASCIIDOC=asciidoctor ASCIIDOC_DOCBOOK=docbook45 ASCIIDOC_HTML=html5 ASCIIDOC_CONF='-I. -rasciidoctor/extensions -rextensions' brian m. carlson (4): Documentation: adjust document title underlining Documentation: fix mismatched delimiters in git-imap-send Documentation: move some AsciiDoc parameters into variables Documentation: implement linkgit macro for Asciidoctor Documentation/Makefile | 18 +++--- Documentation/extensions.rb| 39 ++ Documentation/git-imap-send.txt| 4 ++-- Documentation/git-prune-packed.txt | 2 +- Documentation/git-quiltimport.txt | 2 +- Documentation/git-stage.txt| 2 +- 6 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 Documentation/extensions.rb [0] http://asciidoctor.org/docs/asciidoc-asciidoctor-diffs/ [1] https://github.com/asciidoctor/asciidoctor/pull/1142 -- 2.1.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Performance Issues with Git Rebase
I have what appears to be a fairly straightforward rebase operation and I can't figure out why it seems to effectively hang 'git rebase'. I have a handful of commits that I made last summer and haven't touched since. I'm trying to rebase them against latest on upstream. git status On branch git_enhancements Your branch and 'origin/smb' have diverged, and have 4 and 4665 different commits each, respectively. (use git pull to merge the remote branch into yours) If at this moment I type git rebase it will print out First, rewinding head to replay your work on top of it... And then nothing will happen for approximately 30 minutes, and then it will complete. If I instead type git rebase --onto @{u} HEAD~4 it completes immediately. I've narrowed it down to this line in git-rebase--am (approx. line 65) git format-patch -k --stdout --full-index --cherry-pick --right-only \ --src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \ $revisions ${restrict_revision+^$restrict_revision} \ $GIT_DIR/rebased-patches Which is turned into this in my particular case git format-patch -k --stdout --full-index --cherry-pick --right-only --src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter 451da4975b25797fe54cd11e4796bbd3ee0911ce...ea3cf673d0e76504738bf130d48148d5b96cc406 If I time just that command I get real 32m10.324s user 26m21.296s sys 0m28.994s If I change the triple do to a double dot I get real 0m4.276s user 0m0.096s sys 0m0.022s Which is much more in line with how long I think the command should take. The triple dot is coming from just earlier in the file here if test -z $rebase_root # this is now equivalent to ! -z $upstream then revisions=$upstream...$orig_head else revisions=$onto...$orig_head fi which seems to have been in place for 2+ years. I'm getting the same output with both the triple and double dot for my specific case, but I have no idea if that change makes sense for all cases or not. Any guidance? Thanks much, -Andrew -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] receive-pack: plug minor memory leak in unpack()
On Sat, Oct 11, 2014 at 01:00:16PM +0200, René Scharfe wrote: The argv_array used in unpack() is never freed. Instead of adding explicit calls to argv_array_clear() use the args member of struct child_process and let run_command() and friends clean up for us. Looks good. I notice that the recently added prepare_push_cert_sha1 uses an argv_array to create the child_process.env, and we leak the result. I wonder if run-command should provide a managed env array similar to the args array. -Peff -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
$GIT_DIR/info/exclude fails to negate a pattern defined by core.excludesfile
I have the pattern `*.out` defined in my `core.excludesfile`. According to the documentation[1], patterns defined in `$GIT_DIR/info/exclude` take precedence over `core.excludesfile`, so for one particular project that needs to track some `.out` files, I created `$GIT_DIR/info/exclude` with just one pattern: `!*.out`. Yet for some reason, `git status` still fails to report newly created `.out` files for that project. Am I misunderstanding the documentation? Thanks, D. [1] http://jk.gs/gitignore.html -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/4] Multiple worktrees vs. submodules fixes
Hi. These are fixes of issues with submodules with use of multiple working trees. To be applied on top of the $gmane/257559, (6b4ce012cb in current pu). Max Kirillov (4): checkout: do not fail if target is an empty directory submodule refactor: use git_path_submodule() in add_submodule_odb() git-common-dir: make modules/ per-working-directory directory path: implement common_dir handling in git_path_submodule() Documentation/gitrepository-layout.txt | 4 +-- builtin/checkout.c | 2 +- cache.h| 1 + path.c | 26 +++--- setup.c| 17 +++--- submodule.c| 28 ++- t/t2025-checkout-to.sh | 7 +++- t/t7410-submodule-checkout-to.sh | 62 ++ 8 files changed, 114 insertions(+), 33 deletions(-) create mode 100755 t/t7410-submodule-checkout-to.sh -- 2.0.1.1697.g73c6810 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/4] checkout: do not fail if target is an empty directory
Non-recursive checkout creates empty directpries in place of submodules. If then I try to checkout --to submodules there, it refuses to do so, because directory already exists. Fix by allowing checking out to empty directory. Add test and modify the existing one so that it uses non-empty directory. Signed-off-by: Max Kirillov m...@max630.net --- builtin/checkout.c | 2 +- t/t2025-checkout-to.sh | 7 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index 01d0f2f..74eabe7 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -865,7 +865,7 @@ static int prepare_linked_checkout(const struct checkout_opts *opts, if (!new-commit) die(_(no branch specified)); - if (file_exists(path)) + if (file_exists(path) !is_empty_dir(path)) die(_('%s' already exists), path); len = strlen(path); diff --git a/t/t2025-checkout-to.sh b/t/t2025-checkout-to.sh index eddd325..915b506 100755 --- a/t/t2025-checkout-to.sh +++ b/t/t2025-checkout-to.sh @@ -13,10 +13,15 @@ test_expect_success 'checkout --to not updating paths' ' ' test_expect_success 'checkout --to an existing worktree' ' - mkdir existing + mkdir -p existing/subtree test_must_fail git checkout --detach --to existing master ' +test_expect_success 'checkout --to an existing empty worktree' ' + mkdir existing_empty + git checkout --detach --to existing_empty master +' + test_expect_success 'checkout --to refuses to checkout locked branch' ' test_must_fail git checkout --to zere master ! test -d zere -- 2.0.1.1697.g73c6810 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/4] path: implement common_dir handling in git_path_submodule()
Currently git_path_submodule() does not handle submodules being a linked checkout. The visible result is that git diff --submodule fails to report changes in the submodule. Perform the same resolution as with parent repository, but ignore the GIT_COMMON_DIR environment variable, because it would mean common directory for the parent repository and does not make sense for submodule. Also add test for functionality which uses this call. Signed-off-by: Max Kirillov m...@max630.net --- cache.h | 1 + path.c | 24 setup.c | 17 - t/t7410-submodule-checkout-to.sh | 12 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/cache.h b/cache.h index ab3adb6..09821df 100644 --- a/cache.h +++ b/cache.h @@ -437,6 +437,7 @@ extern char *get_object_directory(void); extern char *get_index_file(void); extern char *get_graft_file(void); extern int set_git_dir(const char *path); +extern int get_common_dir_noenv(struct strbuf *sb, const char *gitdir); extern int get_common_dir(struct strbuf *sb, const char *gitdir); extern const char *get_git_namespace(void); extern const char *strip_namespace(const char *namespaced_ref); diff --git a/path.c b/path.c index a5c51a3..78f718f 100644 --- a/path.c +++ b/path.c @@ -98,7 +98,7 @@ static const char *common_list[] = { NULL }; -static void update_common_dir(struct strbuf *buf, int git_dir_len) +static void update_common_dir(struct strbuf *buf, int git_dir_len, const char* common_dir) { char *base = buf-buf + git_dir_len; const char **p; @@ -115,12 +115,17 @@ static void update_common_dir(struct strbuf *buf, int git_dir_len) path++; is_dir = 1; } + + if (!common_dir) { + common_dir = get_git_common_dir(); + } + if (is_dir dir_prefix(base, path)) { - replace_dir(buf, git_dir_len, get_git_common_dir()); + replace_dir(buf, git_dir_len, common_dir); return; } if (!is_dir !strcmp(base, path)) { - replace_dir(buf, git_dir_len, get_git_common_dir()); + replace_dir(buf, git_dir_len, common_dir); return; } } @@ -160,7 +165,7 @@ static void adjust_git_path(struct strbuf *buf, int git_dir_len) else if (git_db_env dir_prefix(base, objects)) replace_dir(buf, git_dir_len + 7, get_object_directory()); else if (git_common_dir_env) - update_common_dir(buf, git_dir_len); + update_common_dir(buf, git_dir_len, NULL); } static void do_git_path(struct strbuf *buf, const char *fmt, va_list args) @@ -256,6 +261,8 @@ const char *git_path_submodule(const char *path, const char *fmt, ...) { struct strbuf *buf = get_pathname(); const char *git_dir; + struct strbuf git_submodule_common_dir = STRBUF_INIT; + struct strbuf git_submodule_dir = STRBUF_INIT; va_list args; strbuf_addstr(buf, path); @@ -269,11 +276,20 @@ const char *git_path_submodule(const char *path, const char *fmt, ...) strbuf_addstr(buf, git_dir); } strbuf_addch(buf, '/'); + strbuf_addstr(git_submodule_dir, buf-buf); va_start(args, fmt); strbuf_vaddf(buf, fmt, args); va_end(args); + + if (get_common_dir_noenv(git_submodule_common_dir, git_submodule_dir.buf)) { + update_common_dir(buf, git_submodule_dir.len, git_submodule_common_dir.buf); + } + strbuf_cleanup_path(buf); + + strbuf_release(git_submodule_dir); + strbuf_release(git_submodule_common_dir); return buf-buf; } diff --git a/setup.c b/setup.c index fb61860..ffda622 100644 --- a/setup.c +++ b/setup.c @@ -226,14 +226,21 @@ void verify_non_filename(const char *prefix, const char *arg) int get_common_dir(struct strbuf *sb, const char *gitdir) { + const char *git_env_common_dir = getenv(GIT_COMMON_DIR_ENVIRONMENT); + if (git_env_common_dir) { + strbuf_addstr(sb, git_env_common_dir); + return 1; + } else { + return get_common_dir_noenv(sb, gitdir); + } +} + +int get_common_dir_noenv(struct strbuf *sb, const char *gitdir) +{ struct strbuf data = STRBUF_INIT; struct strbuf path = STRBUF_INIT; - const char *git_common_dir = getenv(GIT_COMMON_DIR_ENVIRONMENT); int ret = 0; - if (git_common_dir) { - strbuf_addstr(sb, git_common_dir); - return 1; - } + strbuf_addf(path, %s/commondir, gitdir); if (file_exists(path.buf)) { if (strbuf_read_file(data, path.buf, 0) = 0) diff --git
[PATCH 3/4] git-common-dir: make modules/ per-working-directory directory
Each working directory of main repository has its own working directory of submodule, and in most cases they should be checked out to different revisions. So they should be separated. It looks logical to make submodule instances in different working directories to reuse the submodule directory in the common dir of the main repository, and probably this is how checkout --to should initialize them called on the main repository, but they also should work fine being completely separated clones. Testfile t7410-submodule-checkout-to.sh demostrates the behavior. Signed-off-by: Max Kirillov m...@max630.net --- Documentation/gitrepository-layout.txt | 4 +-- path.c | 2 +- t/t7410-submodule-checkout-to.sh | 50 ++ 3 files changed, 52 insertions(+), 4 deletions(-) create mode 100755 t/t7410-submodule-checkout-to.sh diff --git a/Documentation/gitrepository-layout.txt b/Documentation/gitrepository-layout.txt index 2b30a92..7173b38 100644 --- a/Documentation/gitrepository-layout.txt +++ b/Documentation/gitrepository-layout.txt @@ -248,9 +248,7 @@ commondir:: incomplete without the repository pointed by commondir. modules:: - Contains the git-repositories of the submodules. This - directory is ignored if $GIT_COMMON_DIR is set and - $GIT_COMMON_DIR/modules will be used instead. + Contains the git-repositories of the submodules. worktrees:: Contains worktree specific information of linked diff --git a/path.c b/path.c index 35d498e..a5c51a3 100644 --- a/path.c +++ b/path.c @@ -92,7 +92,7 @@ static void replace_dir(struct strbuf *buf, int len, const char *newdir) } static const char *common_list[] = { - /branches, /hooks, /info, !/logs, /lost-found, /modules, + /branches, /hooks, /info, !/logs, /lost-found, /objects, /refs, /remotes, /worktrees, /rr-cache, /svn, config, !gc.pid, packed-refs, shallow, NULL diff --git a/t/t7410-submodule-checkout-to.sh b/t/t7410-submodule-checkout-to.sh new file mode 100755 index 000..8f30aed --- /dev/null +++ b/t/t7410-submodule-checkout-to.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +test_description='Combination of submodules and multiple workdirs' + +. ./test-lib.sh + +base_path=$(pwd -P) + +test_expect_success 'setup: make origin' \ +'mkdir -p origin/sub ( cd origin/sub git init + echo file1 file1 + git add file1 + git commit -m file1 ) +mkdir -p origin/main ( cd origin/main git init + git submodule add ../sub + git commit -m add sub ) +( cd origin/sub + echo file1updated file1 + git add file1 + git commit -m file1 updated ) +( cd origin/main/sub git pull ) +( cd origin/main + git add sub + git commit -m sub updated )' + +test_expect_success 'setup: clone' \ +'mkdir clone ( cd clone + git clone --recursive $base_path/origin/main)' + +rev1_hash_main=$(git --git-dir=origin/main/.git show --pretty=format:%h -q HEAD~1) +rev1_hash_sub=$(git --git-dir=origin/sub/.git show --pretty=format:%h -q HEAD~1) + +test_expect_success 'checkout main' \ +'mkdir default_checkout +(cd clone/main + git checkout --to $base_path/default_checkout/main $rev1_hash_main)' + +test_expect_failure 'can see submodule diffs just after checkout' \ +'(cd default_checkout/main git diff --submodule master^! | grep file1 updated)' + +test_expect_success 'checkout main and initialize independed clones' \ +'mkdir fully_cloned_submodule +(cd clone/main + git checkout --to $base_path/fully_cloned_submodule/main $rev1_hash_main) +(cd fully_cloned_submodule/main git submodule update)' + +test_expect_success 'can see submodule diffs after independed cloning' \ +'(cd fully_cloned_submodule/main git diff --submodule master^! | grep file1 updated)' + +test_done -- 2.0.1.1697.g73c6810 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/4] submodule refactor: use git_path_submodule() in add_submodule_odb()
Signed-off-by: Max Kirillov m...@max630.net --- submodule.c | 28 ++-- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/submodule.c b/submodule.c index 34094f5..4aad3d4 100644 --- a/submodule.c +++ b/submodule.c @@ -122,43 +122,35 @@ void stage_updated_gitmodules(void) static int add_submodule_odb(const char *path) { - struct strbuf objects_directory = STRBUF_INIT; struct alternate_object_database *alt_odb; + const char* objects_directory; int ret = 0; - const char *git_dir; - strbuf_addf(objects_directory, %s/.git, path); - git_dir = read_gitfile(objects_directory.buf); - if (git_dir) { - strbuf_reset(objects_directory); - strbuf_addstr(objects_directory, git_dir); - } - strbuf_addstr(objects_directory, /objects/); - if (!is_directory(objects_directory.buf)) { + objects_directory = git_path_submodule(path, objects/); + if (!is_directory(objects_directory)) { ret = -1; goto done; } + /* avoid adding it twice */ for (alt_odb = alt_odb_list; alt_odb; alt_odb = alt_odb-next) - if (alt_odb-name - alt_odb-base == objects_directory.len - !strncmp(alt_odb-base, objects_directory.buf, - objects_directory.len)) + if (alt_odb-name - alt_odb-base == strlen(objects_directory) + !strcmp(alt_odb-base, objects_directory)) goto done; - alt_odb = xmalloc(objects_directory.len + 42 + sizeof(*alt_odb)); + alt_odb = xmalloc(strlen(objects_directory) + 42 + sizeof(*alt_odb)); alt_odb-next = alt_odb_list; - strcpy(alt_odb-base, objects_directory.buf); - alt_odb-name = alt_odb-base + objects_directory.len; + strcpy(alt_odb-base, objects_directory); + alt_odb-name = alt_odb-base + strlen(objects_directory); alt_odb-name[2] = '/'; alt_odb-name[40] = '\0'; alt_odb-name[41] = '\0'; alt_odb_list = alt_odb; /* add possible alternates from the submodule */ - read_info_alternates(objects_directory.buf, 0); + read_info_alternates(objects_directory, 0); prepare_alt_odb(); done: - strbuf_release(objects_directory); return ret; } -- 2.0.1.1697.g73c6810 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html