Re: [PATCH 41/68] init: use strbufs to store paths
On 10/01/2015 04:51 AM, Jeff King wrote: On Wed, Sep 30, 2015 at 01:00:56PM -0700, Junio C Hamano wrote: Wow, my patch isn't even close to reasonable. I didn't realize because we do not compile this code at all for non-Mac platforms. Sorry. Perhaps the way we completely stub out the platform specific helpers contributes to this kind of gotchas? I am wondering how much additional safety we would gain if we start doing something like this. I think it is an improvement, but it does not solve all of the problems. I also botched the implementation of probe_utf8_pathname_composition, and that does not get compiled on most platforms (though we _could_ compile it and just never call it). -Peff Peff, are you planing a re-roll ? Or. Junio, do you plan to fix it ? Or should I send a patch on top of pu ? The compilation can be tested under Linux like this: diff --git a/config.mak.uname b/config.mak.uname index 7486a7e..6d09bd0 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -13,6 +13,9 @@ ifdef MSVC uname_O := Windows endif +COMPAT_OBJS += compat/precompose_utf8.o +BASIC_CFLAGS += -DPRECOMPOSE_UNICODE + -- 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/RFC 1/2] sha1_file: close all pack files after running
Hi Max, On 2015-10-01 05:29, Max Kirillov wrote: > When a builtin has done its job, but waits for pager or not waited > by its caller and still hanging it keeps pack files opened. > This can cause a number of issues, for example on Windows git gc > cannot remove the packs. I did not experience that issue. In any case, closing the packs after the builtin function has returned might not change anything anyway because we are about to `exit()` and that's that. So I would like to skip this: > diff --git a/git.c b/git.c > index 5feba41..ad34680 100644 > --- a/git.c > +++ b/git.c > @@ -348,6 +349,7 @@ static int run_builtin(struct cmd_struct *p, int > argc, const char **argv) > trace_argv_printf(argv, "trace: built-in: git"); > > status = p->fn(argc, argv, prefix); > + close_all_packs(); > if (status) > return status; > Also, I would move the new declaration directly before `close_pack_windows()`: > diff --git a/cache.h b/cache.h > index 79066e5..153bc46 100644 > --- a/cache.h > +++ b/cache.h > @@ -1279,6 +1279,7 @@ extern void unuse_pack(struct pack_window **); > extern void free_pack_by_name(const char *); > extern void clear_delta_base_cache(void); > extern struct packed_git *add_packed_git(const char *, int, int); > +extern void close_all_packs(void); > > /* > * Return the SHA-1 of the nth object within the specified packfile. The convention in Git seems to call things _gently rather than _nodie: > diff --git a/sha1_file.c b/sha1_file.c > index 08302f5..62f1dad 100644 > --- a/sha1_file.c > +++ b/sha1_file.c > @@ -773,20 +773,28 @@ void *xmmap(void *start, size_t length, > return ret; > } > > -void close_pack_windows(struct packed_git *p) > +static int close_pack_windows_nodie(struct packed_git *p) > { > while (p->windows) { > struct pack_window *w = p->windows; > > if (w->inuse_cnt) > - die("pack '%s' still has open windows to it", > - p->pack_name); > + return 1; > + > munmap(w->base, w->len); > pack_mapped -= w->len; > pack_open_windows--; > p->windows = w->next; > free(w); > } > + > + return 0; > +} And while we're at it, why not teach that function a new parameter `int close_pack_fd`? There is another problem: when we cannot close the pack window, we cannot really continue, can we? Because if we do, we *still* have the lock, and we'll just fail later, most likely with an unhelpful error message because we do not know where the pack closing failed. I do not think that the warning really helps... Ciao, Dscho -- 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: Convenient shortcut to push delete current branch?
On Thu, Oct 1, 2015 at 2:37 PM, Robert Daileywrote: > On Thu, Oct 1, 2015 at 1:22 PM, Jacob Keller wrote: >> On Thu, Oct 1, 2015 at 9:43 AM, Robert Dailey >> wrote: >>> For convenient pushing of current branch, git supports this syntax: >>> >>> $ git push origin HEAD >>> >>> This will push your current branch up. However, is there such a >>> shortcut for *deleting* the branch? The only goal here is to avoid >>> having to type the branch name in the push command. Normally I rely on >>> tab completion but we have tons of branches, all which start with some >>> prefix mixed with numbers, so it becomes cumbersome to rely on tab >>> completion. Ideally I'd like to be able to do: >>> >>> $ git push --delete origin HEAD >>> $ git push origin :HEAD >>> >>> Is there a syntax like this available? >> >> You can do >> >> git push origin: >> >> but I don't believe HEAD is supported. It might be valuable to extend >> push to have a --delete option which would maybe be useful for those >> who didn't learn the full refspec syntax. > > Push already has a --delete option. > I could see adding an option for --delete-upstream that would use the upstream remote and ref of the current branch (if they exist). External to git you could script this from the config (completely untested): if branch=$(git symbolic-ref --short HEAD); then if remote=$(git config branch.$branch.remote); then if remote_ref=$(git config branch.$branch.merge); then git push $remote --delete $remote_ref fi fi fi >> I don't think git push origin :HEAD makes too much sense, since that's >> on the remote side of a refspec, and you want it interpreted >> locally... I suppose it makes sense somewhat, but other refspecs with >> HEAD on the remote side of the refspec don't really make sense, where >> as HEAD always makes sense on the local side of the refspec. > > HEAD makes sense on the remote side if you think of it like an alias: > > HEAD -> branch-name -> SHA1 > > HEAD simply points to branch-name. It makes sense for git to assume > that we should never do anything with real HEAD ref on the remote > side, and instead treat it as a substitution for the remote name. My > assumption may not be correct, but at the very least it should be a > niche case. > -- > 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 -- 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: can't install on OS X
- Original Message - > From: "Spencer Graves"> Sent: Friday, October 2, 2015 2:50:30 AM > Subject: can't install on OS X > > I downloaded "git-2.5.3-intel-universal-mavericks.dmg" per > instructions. When I tried to install it, I first had trouble because > it wasn't from the Mac App Store nor an "identified developer". You can also right click on the installer and select "Open" for a very similar dialog, but one that gives you the opportunity to run the installer anyway. > "README.txt" says I need "sudo mv /usr/bin/git /usr/bin/git-system". I > tried that and got, "mv: rename /usr/bin/git to /usr/bin/git-system: > Operation not permitted" (after entering my password). [My directory > now includes "/usr/local/git", and "/usr/bin" includes git, > git-cvsserver, git-receive-pack, git-shell, git-upload-archive, and > git-upload-pack.] > > Suggestions? Sounds like you're running afoul of El Capitan's new System Integrity Protection (SIP) [1]. The git commands you're seeing there are probably Apple's thin wrappers that are mostly meant to provide instructions on installing XCode, but SIP is stopping you from modifying the /usr directory (ah, Apple's Infinite Wisdom). There are discussions about working around SIP in the Apple forums [2] and Homebrew has some hints as well [3]. [1] https://developer.apple.com/library/prerelease/mac/releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_11.html [2] https://forums.developer.apple.com/thread/3981 [3] https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/El_Capitan_and_Homebrew.md#if-usrlocal-does-not-exist HTH, Stephen -- 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: can't install on OS X
On 10/2/2015 7:02 AM, Mike Rappazzo wrote: Looks like you have it installed properly. The typical usage is from the terminal, (try `git --version` to be sure). a-MacBook-Pro:~ sbgraves$ git --version xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun ??? There is also a pretty great UI packaged with git called git-gui. You should be able to make a link or an alias to it in your Applications folder (or invoke it from the terminal `git gui`). How? Thanks very much for the reply. Spencer Graves On Fri, Oct 2, 2015 at 2:50 AM, Spencer Graveswrote: What's the procedure for installing Git under OS X 10.11? I downloaded "git-2.5.3-intel-universal-mavericks.dmg" per instructions. When I tried to install it, I first had trouble because it wasn't from the Mac App Store nor an "identified developer". I ultimately found "System Preferences" > "Security & Privacy" > "Click the lock to make changes" > entered password > AND clicked to "Allow apps downloaded from: Anywhere". Then the install appeared to run and proclaimed, "The installation was successful." However, git is not listed under "Applications", and RStudio says, "Git was not detected on the system path." "README.txt" says I need "sudo mv /usr/bin/git /usr/bin/git-system". I tried that and got, "mv: rename /usr/bin/git to /usr/bin/git-system: Operation not permitted" (after entering my password). [My directory now includes "/usr/local/git", and "/usr/bin" includes git, git-cvsserver, git-receive-pack, git-shell, git-upload-archive, and git-upload-pack.] Suggestions? Thanks, Spencer Graves -- 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 -- 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/RFC 1/2] sha1_file: close all pack files after running
Hi Max, On 2015-10-02 12:05, Johannes Schindelin wrote: > On 2015-10-01 05:29, Max Kirillov wrote: >> When a builtin has done its job, but waits for pager or not waited >> by its caller and still hanging it keeps pack files opened. >> This can cause a number of issues, for example on Windows git gc >> cannot remove the packs. Could you do me another favor? It seems that you want to work on this, so I will step back (I have to take off for the weekend very soon anyway, so I am really glad that you take care of it). But I would really love to see the line This fixes https://github.com/git-for-windows/git/issues/446 in the commit message, as this will keep the connection between the fix and the original report. Thanks, Dscho -- 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 v9 4/5] worktree: add details to the worktree struct
In addition to the absolute path in the worktree struct, add the location of the git dir, the head ref (if not detached), the head revision sha1, whether or not head is detached, and whether or not the worktree is a bare repo. Signed-off-by: Michael Rappazzo--- worktree.c | 55 --- worktree.h | 4 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/worktree.c b/worktree.c index 11a3364..27af98a 100644 --- a/worktree.c +++ b/worktree.c @@ -9,6 +9,8 @@ void free_worktrees(struct worktree **worktrees) for (i = 0; worktrees[i]; i++) { free(worktrees[i]->path); + free(worktrees[i]->git_dir); + free(worktrees[i]->head_ref); free(worktrees[i]); } free (worktrees); @@ -48,6 +50,21 @@ static int parse_ref(char *path_to_ref, struct strbuf *ref, int *is_detached) } /** + * Add the head_sha1 and head_ref (if not detached) to the given worktree + */ +static void add_head_info(struct strbuf *head_ref, struct worktree *worktree) +{ + if (head_ref->len) { + if (worktree->is_detached) { + get_sha1_hex(head_ref->buf, worktree->head_sha1); + } else { + resolve_ref_unsafe(head_ref->buf, 0, worktree->head_sha1, NULL); + worktree->head_ref = strbuf_detach(head_ref, NULL); + } + } +} + +/** * get the main worktree */ static struct worktree *get_main_worktree(void) @@ -57,19 +74,29 @@ static struct worktree *get_main_worktree(void) struct strbuf worktree_path = STRBUF_INIT; struct strbuf gitdir = STRBUF_INIT; struct strbuf head_ref = STRBUF_INIT; + int is_bare = 0; + int is_detached = 0; strbuf_addf(, "%s", absolute_path(get_git_common_dir())); strbuf_addbuf(_path, ); - if (!strbuf_strip_suffix(_path, "/.git")) + is_bare = !strbuf_strip_suffix(_path, "/.git"); + if (is_bare) strbuf_strip_suffix(_path, "/."); strbuf_addf(, "%s/HEAD", get_git_common_dir()); - if (parse_ref(path.buf, _ref, NULL) >= 0) { - worktree = xmalloc(sizeof(struct worktree)); - worktree->path = strbuf_detach(_path, NULL); - worktree->git_dir = strbuf_detach(, NULL); - } + if (parse_ref(path.buf, _ref, _detached) < 0) + goto done; + + worktree = xmalloc(sizeof(struct worktree)); + worktree->path = strbuf_detach(_path, NULL); + worktree->git_dir = strbuf_detach(, NULL); + worktree->is_bare = is_bare; + worktree->head_ref = NULL; + worktree->is_detached = is_detached; + add_head_info(_ref, worktree); + +done: strbuf_release(); strbuf_release(); strbuf_release(_path); @@ -84,6 +111,7 @@ static struct worktree *get_linked_worktree(const char *id) struct strbuf worktree_path = STRBUF_INIT; struct strbuf gitdir = STRBUF_INIT; struct strbuf head_ref = STRBUF_INIT; + int is_detached = 0; if (!id) die("Missing linked worktree name"); @@ -105,11 +133,16 @@ static struct worktree *get_linked_worktree(const char *id) strbuf_reset(); strbuf_addf(, "%s/worktrees/%s/HEAD", get_git_common_dir(), id); - if (parse_ref(path.buf, _ref, NULL) >= 0) { - worktree = xmalloc(sizeof(struct worktree)); - worktree->path = strbuf_detach(_path, NULL); - worktree->git_dir = strbuf_detach(, NULL); - } + if (parse_ref(path.buf, _ref, _detached) < 0) + goto done; + + worktree = xmalloc(sizeof(struct worktree)); + worktree->path = strbuf_detach(_path, NULL); + worktree->git_dir = strbuf_detach(, NULL); + worktree->is_bare = 0; + worktree->head_ref = NULL; + worktree->is_detached = is_detached; + add_head_info(_ref, worktree); done: strbuf_release(); diff --git a/worktree.h b/worktree.h index 7022029..b4b3dda 100644 --- a/worktree.h +++ b/worktree.h @@ -4,6 +4,10 @@ struct worktree { char *path; char *git_dir; + char *head_ref; + unsigned char head_sha1[20]; + int is_detached; + int is_bare; }; /* Functions for acting on the information about worktrees. */ -- 2.6.0 -- 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 v9 1/5] worktree: add top-level worktree.c
worktree.c contains functions to work with and get information from worktrees. This introduction moves functions related to worktrees from branch.c into worktree.c Signed-off-by: Michael Rappazzo--- Makefile| 1 + branch.c| 79 +- branch.h| 8 -- builtin/notes.c | 2 +- worktree.c | 82 + worktree.h | 12 + 6 files changed, 97 insertions(+), 87 deletions(-) create mode 100644 worktree.c create mode 100644 worktree.h diff --git a/Makefile b/Makefile index 8d5df7e..f4ee2d2 100644 --- a/Makefile +++ b/Makefile @@ -807,6 +807,7 @@ LIB_OBJS += version.o LIB_OBJS += versioncmp.o LIB_OBJS += walker.o LIB_OBJS += wildmatch.o +LIB_OBJS += worktree.o LIB_OBJS += wrapper.o LIB_OBJS += write_or_die.o LIB_OBJS += ws.o diff --git a/branch.c b/branch.c index d013374..77d7f2a 100644 --- a/branch.c +++ b/branch.c @@ -4,6 +4,7 @@ #include "refs.h" #include "remote.h" #include "commit.h" +#include "worktree.h" struct tracking { struct refspec spec; @@ -311,84 +312,6 @@ void remove_branch_state(void) unlink(git_path_squash_msg()); } -static char *find_linked_symref(const char *symref, const char *branch, - const char *id) -{ - struct strbuf sb = STRBUF_INIT; - struct strbuf path = STRBUF_INIT; - struct strbuf gitdir = STRBUF_INIT; - char *existing = NULL; - - /* -* $GIT_COMMON_DIR/$symref (e.g. HEAD) is practically outside -* $GIT_DIR so resolve_ref_unsafe() won't work (it uses -* git_path). Parse the ref ourselves. -*/ - if (id) - strbuf_addf(, "%s/worktrees/%s/%s", get_git_common_dir(), id, symref); - else - strbuf_addf(, "%s/%s", get_git_common_dir(), symref); - - if (!strbuf_readlink(, path.buf, 0)) { - if (!starts_with(sb.buf, "refs/") || - check_refname_format(sb.buf, 0)) - goto done; - } else if (strbuf_read_file(, path.buf, 0) >= 0 && - starts_with(sb.buf, "ref:")) { - strbuf_remove(, 0, strlen("ref:")); - strbuf_trim(); - } else - goto done; - if (strcmp(sb.buf, branch)) - goto done; - if (id) { - strbuf_reset(); - strbuf_addf(, "%s/worktrees/%s/gitdir", get_git_common_dir(), id); - if (strbuf_read_file(, path.buf, 0) <= 0) - goto done; - strbuf_rtrim(); - } else - strbuf_addstr(, get_git_common_dir()); - strbuf_strip_suffix(, ".git"); - - existing = strbuf_detach(, NULL); -done: - strbuf_release(); - strbuf_release(); - strbuf_release(); - - return existing; -} - -char *find_shared_symref(const char *symref, const char *target) -{ - struct strbuf path = STRBUF_INIT; - DIR *dir; - struct dirent *d; - char *existing; - - if ((existing = find_linked_symref(symref, target, NULL))) - return existing; - - strbuf_addf(, "%s/worktrees", get_git_common_dir()); - dir = opendir(path.buf); - strbuf_release(); - if (!dir) - return NULL; - - while ((d = readdir(dir)) != NULL) { - if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) - continue; - existing = find_linked_symref(symref, target, d->d_name); - if (existing) - goto done; - } -done: - closedir(dir); - - return existing; -} - void die_if_checked_out(const char *branch) { char *existing; diff --git a/branch.h b/branch.h index d3446ed..58aa45f 100644 --- a/branch.h +++ b/branch.h @@ -59,12 +59,4 @@ extern int read_branch_desc(struct strbuf *, const char *branch_name); */ extern void die_if_checked_out(const char *branch); -/* - * Check if a per-worktree symref points to a ref in the main worktree - * or any linked worktree, and return the path to the exising worktree - * if it is. Returns NULL if there is no existing ref. The caller is - * responsible for freeing the returned path. - */ -extern char *find_shared_symref(const char *symref, const char *target); - #endif diff --git a/builtin/notes.c b/builtin/notes.c index 3608c64..13c0af9 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -19,7 +19,7 @@ #include "string-list.h" #include "notes-merge.h" #include "notes-utils.h" -#include "branch.h" +#include "worktree.h" static const char * const git_notes_usage[] = { N_("git notes [--ref ] [list []]"), diff --git a/worktree.c b/worktree.c new file mode 100644 index 000..10e1496 --- /dev/null +++ b/worktree.c @@ -0,0 +1,82 @@ +#include "cache.h" +#include "refs.h" +#include "strbuf.h" +#include "worktree.h" + +static char
[PATCH v9 0/5] worktree: list functions and command
Notable changes since v8[1]: - Rework the commit history to try to better maintain blame - Use ALLOC_GROW instead of pre-allocating when building the worktree array - Refine the `--porcelain` format and describe it in the documentation - Remove whitespace from expected and actual test output [1]: http://thread.gmane.org/gmane.comp.version-control.git/278190 Michael Rappazzo (5): worktree: add top-level worktree.c worktree: refactor find_linked_symref function worktree: add a function to get worktree details worktree: add details to the worktree struct worktree: add 'list' command Documentation/git-worktree.txt | 49 +- Makefile | 1 + branch.c | 79 +-- branch.h | 8 -- builtin/notes.c| 2 +- builtin/worktree.c | 82 t/t2027-worktree-list.sh | 89 + worktree.c | 216 + worktree.h | 38 9 files changed, 476 insertions(+), 88 deletions(-) create mode 100755 t/t2027-worktree-list.sh create mode 100644 worktree.c create mode 100644 worktree.h -- 2.6.0 -- 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 v9 3/5] worktree: add a function to get worktree details
The worktree structure provided for an individual worktree includes the absolute path of the worktree. The fuction to get the worktree details is a refactor of the find main/linked symref functions. Signed-off-by: Michael Rappazzo--- worktree.c | 161 ++--- worktree.h | 22 + 2 files changed, 133 insertions(+), 50 deletions(-) diff --git a/worktree.c b/worktree.c index c049947..11a3364 100644 --- a/worktree.c +++ b/worktree.c @@ -3,6 +3,17 @@ #include "strbuf.h" #include "worktree.h" +void free_worktrees(struct worktree **worktrees) +{ + int i = 0; + + for (i = 0; worktrees[i]; i++) { + free(worktrees[i]->path); + free(worktrees[i]); + } + free (worktrees); +} + /* * read 'path_to_ref' into 'ref'. Also if is_detached is not NULL, * set is_detached to 1 (0) if the ref is detatched (is not detached). @@ -17,15 +28,15 @@ static int parse_ref(char *path_to_ref, struct strbuf *ref, int *is_detached) { if (is_detached) *is_detached = 0; - if (!strbuf_readlink(ref, path_to_ref, 0)) + if (!strbuf_readlink(ref, path_to_ref, 0)) { if (!starts_with(ref->buf, "refs/") || check_refname_format(ref->buf, 0)) return -1; - else if (strbuf_read_file(ref, path_to_ref, 0) >= 0) { - if (!starts_with(ref->buf, "ref:")) + } else if (strbuf_read_file(ref, path_to_ref, 0) >= 0) { + if (!starts_with(ref->buf, "ref:")) { if (is_detached) *is_detached = 1; - else { + } else { strbuf_remove(ref, 0, strlen("ref:")); strbuf_trim(ref); if (check_refname_format(ref->buf, 0)) @@ -36,87 +47,137 @@ static int parse_ref(char *path_to_ref, struct strbuf *ref, int *is_detached) return 0; } -static char *find_main_symref(const char *symref, const char *branch) +/** + * get the main worktree + */ +static struct worktree *get_main_worktree(void) { - struct strbuf sb = STRBUF_INIT; + struct worktree *worktree = NULL; struct strbuf path = STRBUF_INIT; + struct strbuf worktree_path = STRBUF_INIT; struct strbuf gitdir = STRBUF_INIT; - char *existing = NULL; + struct strbuf head_ref = STRBUF_INIT; - strbuf_addf(, "%s/%s", get_git_common_dir(), symref); - if (parse_ref(path.buf, , NULL) < 0) - goto done; - if (strcmp(sb.buf, branch)) - goto done; - strbuf_addstr(, get_git_common_dir()); - strbuf_strip_suffix(, ".git"); - existing = strbuf_detach(, NULL); -done: + strbuf_addf(, "%s", absolute_path(get_git_common_dir())); + strbuf_addbuf(_path, ); + if (!strbuf_strip_suffix(_path, "/.git")) + strbuf_strip_suffix(_path, "/."); + + strbuf_addf(, "%s/HEAD", get_git_common_dir()); + + if (parse_ref(path.buf, _ref, NULL) >= 0) { + worktree = xmalloc(sizeof(struct worktree)); + worktree->path = strbuf_detach(_path, NULL); + worktree->git_dir = strbuf_detach(, NULL); + } strbuf_release(); - strbuf_release(); strbuf_release(); - - return existing; + strbuf_release(_path); + strbuf_release(_ref); + return worktree; } -static char *find_linked_symref(const char *symref, const char *branch, - const char *id) +static struct worktree *get_linked_worktree(const char *id) { - struct strbuf sb = STRBUF_INIT; + struct worktree *worktree = NULL; struct strbuf path = STRBUF_INIT; + struct strbuf worktree_path = STRBUF_INIT; struct strbuf gitdir = STRBUF_INIT; - char *existing = NULL; + struct strbuf head_ref = STRBUF_INIT; if (!id) die("Missing linked worktree name"); - strbuf_addf(, "%s/worktrees/%s/%s", get_git_common_dir(), id, symref); - - if (parse_ref(path.buf, , NULL) < 0) - goto done; - if (strcmp(sb.buf, branch)) + strbuf_addf(, "%s/worktrees/%s", + absolute_path(get_git_common_dir()), id); + strbuf_addf(, "%s/gitdir", gitdir.buf); + if (strbuf_read_file(_path, path.buf, 0) <= 0) + /* invalid gitdir file */ goto done; + + strbuf_rtrim(_path); + if (!strbuf_strip_suffix(_path, "/.git")) { + strbuf_reset(_path); + strbuf_addstr(_path, absolute_path(".")); + strbuf_strip_suffix(_path, "/."); + } + strbuf_reset(); - strbuf_addf(, "%s/worktrees/%s/gitdir", get_git_common_dir(), id); - if (strbuf_read_file(, path.buf, 0) <= 0) - goto done; - strbuf_rtrim();
[PATCH v9 2/5] worktree: refactor find_linked_symref function
Refactoring will help transition this code to provide additional useful worktree functions. Signed-off-by: Michael Rappazzo--- worktree.c | 94 -- 1 file changed, 67 insertions(+), 27 deletions(-) diff --git a/worktree.c b/worktree.c index 10e1496..c049947 100644 --- a/worktree.c +++ b/worktree.c @@ -3,6 +3,62 @@ #include "strbuf.h" #include "worktree.h" +/* + * read 'path_to_ref' into 'ref'. Also if is_detached is not NULL, + * set is_detached to 1 (0) if the ref is detatched (is not detached). + * + * $GIT_COMMON_DIR/$symref (e.g. HEAD) is practically outside $GIT_DIR so + * for linked worktrees, `resolve_ref_unsafe()` won't work (it uses + * git_path). Parse the ref ourselves. + * + * return -1 if the ref is not a proper ref, 0 otherwise (success) + */ +static int parse_ref(char *path_to_ref, struct strbuf *ref, int *is_detached) +{ + if (is_detached) + *is_detached = 0; + if (!strbuf_readlink(ref, path_to_ref, 0)) + if (!starts_with(ref->buf, "refs/") || + check_refname_format(ref->buf, 0)) + return -1; + else if (strbuf_read_file(ref, path_to_ref, 0) >= 0) { + if (!starts_with(ref->buf, "ref:")) + if (is_detached) + *is_detached = 1; + else { + strbuf_remove(ref, 0, strlen("ref:")); + strbuf_trim(ref); + if (check_refname_format(ref->buf, 0)) + return -1; + } + } else + return -1; + return 0; +} + +static char *find_main_symref(const char *symref, const char *branch) +{ + struct strbuf sb = STRBUF_INIT; + struct strbuf path = STRBUF_INIT; + struct strbuf gitdir = STRBUF_INIT; + char *existing = NULL; + + strbuf_addf(, "%s/%s", get_git_common_dir(), symref); + if (parse_ref(path.buf, , NULL) < 0) + goto done; + if (strcmp(sb.buf, branch)) + goto done; + strbuf_addstr(, get_git_common_dir()); + strbuf_strip_suffix(, ".git"); + existing = strbuf_detach(, NULL); +done: + strbuf_release(); + strbuf_release(); + strbuf_release(); + + return existing; +} + static char *find_linked_symref(const char *symref, const char *branch, const char *id) { @@ -11,36 +67,20 @@ static char *find_linked_symref(const char *symref, const char *branch, struct strbuf gitdir = STRBUF_INIT; char *existing = NULL; - /* -* $GIT_COMMON_DIR/$symref (e.g. HEAD) is practically outside -* $GIT_DIR so resolve_ref_unsafe() won't work (it uses -* git_path). Parse the ref ourselves. -*/ - if (id) - strbuf_addf(, "%s/worktrees/%s/%s", get_git_common_dir(), id, symref); - else - strbuf_addf(, "%s/%s", get_git_common_dir(), symref); + if (!id) + die("Missing linked worktree name"); - if (!strbuf_readlink(, path.buf, 0)) { - if (!starts_with(sb.buf, "refs/") || - check_refname_format(sb.buf, 0)) - goto done; - } else if (strbuf_read_file(, path.buf, 0) >= 0 && - starts_with(sb.buf, "ref:")) { - strbuf_remove(, 0, strlen("ref:")); - strbuf_trim(); - } else + strbuf_addf(, "%s/worktrees/%s/%s", get_git_common_dir(), id, symref); + + if (parse_ref(path.buf, , NULL) < 0) goto done; if (strcmp(sb.buf, branch)) goto done; - if (id) { - strbuf_reset(); - strbuf_addf(, "%s/worktrees/%s/gitdir", get_git_common_dir(), id); - if (strbuf_read_file(, path.buf, 0) <= 0) - goto done; - strbuf_rtrim(); - } else - strbuf_addstr(, get_git_common_dir()); + strbuf_reset(); + strbuf_addf(, "%s/worktrees/%s/gitdir", get_git_common_dir(), id); + if (strbuf_read_file(, path.buf, 0) <= 0) + goto done; + strbuf_rtrim(); strbuf_strip_suffix(, ".git"); existing = strbuf_detach(, NULL); @@ -59,7 +99,7 @@ char *find_shared_symref(const char *symref, const char *target) struct dirent *d; char *existing; - if ((existing = find_linked_symref(symref, target, NULL))) + if ((existing = find_main_symref(symref, target))) return existing; strbuf_addf(, "%s/worktrees", get_git_common_dir()); -- 2.6.0 -- 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 v9 5/5] worktree: add 'list' command
'git worktree list' iterates through the worktree list, and outputs details of the worktree including the path to the worktree, the currently checked out revision and branch, and if the work tree is bare. There is also porcelain format option available. Signed-off-by: Michael Rappazzo--- Documentation/git-worktree.txt | 49 ++- builtin/worktree.c | 82 ++ t/t2027-worktree-list.sh | 89 ++ 3 files changed, 219 insertions(+), 1 deletion(-) create mode 100755 t/t2027-worktree-list.sh diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index fb68156..5b9ad04 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -11,6 +11,7 @@ SYNOPSIS [verse] 'git worktree add' [-f] [--detach] [-b ] [] 'git worktree prune' [-n] [-v] [--expire ] +'git worktree list' [--porcelain] DESCRIPTION --- @@ -59,6 +60,13 @@ prune:: Prune working tree information in $GIT_DIR/worktrees. +list:: + +List details of each worktree. The main worktree is listed first, followed by +each of the linked worktrees. The output details include if the worktree is +bare, the revision currently checked out, and the branch currently checked out +(or 'detached HEAD' if none). + OPTIONS --- @@ -86,6 +94,11 @@ OPTIONS With `prune`, do not remove anything; just report what it would remove. +--porcelain:: + With `list`, output in an easy-to-parse format for scripts. + This format will remain stable across Git versions and regardless of user + configuration. See below for details. + -v:: --verbose:: With `prune`, report all removals. @@ -134,6 +147,41 @@ to `/path/main/.git/worktrees/test-next` then a file named `test-next` entry from being pruned. See linkgit:gitrepository-layout[5] for details. +LIST OUTPUT FORMAT +-- +The worktree list command has two output formats. The default format shows the +details on a single line with columns. For example: + + +S git worktree list +/path/to/bare-source(bare) +/path/to/linked-worktreeabcd1234 [master] +/path/to/other-linked-worktree 1234abc (detached HEAD) + + +Porcelain Format + +The porcelain format has a line per attribute. Attributes are listed with a +label and value separated by a single space. Boolean attributes (like 'bare' +and 'detached') are listed as a label only, and are only present if and only +if the value is true. An empty line indicates the end of a worktree. For +example: + + +S git worktree list --porcelain +worktree /path/to/bare-source +bare + +worktree /path/to/linked-worktree +HEAD abcd1234abcd1234abcd1234abcd1234abcd1234 +branch refs/heads/master + +worktree /path/to/other-linked-worktree +HEAD 1234abc1234abc1234abc1234abc1234abc1234a +detached + + + EXAMPLES You are in the middle of a refactoring session and your boss comes in and @@ -167,7 +215,6 @@ performed manually, such as: - `remove` to remove a linked working tree and its administrative files (and warn if the working tree is dirty) - `mv` to move or rename a working tree and update its administrative files -- `list` to list linked working trees - `lock` to prevent automatic pruning of administrative files (for instance, for a working tree on a portable device) diff --git a/builtin/worktree.c b/builtin/worktree.c index 71bb770..268f9bf 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -8,10 +8,13 @@ #include "run-command.h" #include "sigchain.h" #include "refs.h" +#include "utf8.h" +#include "worktree.h" static const char * const worktree_usage[] = { N_("git worktree add [] "), N_("git worktree prune []"), + N_("git worktree list []"), NULL }; @@ -359,6 +362,83 @@ static int add(int ac, const char **av, const char *prefix) return add_worktree(path, branch, ); } +static void show_worktree_porcelain(struct worktree *worktree) +{ + printf("worktree %s\n", worktree->path); + if (worktree->is_bare) + printf("bare\n"); + else { + printf("HEAD %s\n", sha1_to_hex(worktree->head_sha1)); + if (worktree->is_detached) + printf("detached\n"); + else + printf("branch %s\n", worktree->head_ref); + } + printf("\n"); +} +static void show_worktree( + struct worktree *worktree, int path_maxlen, int abbrev_len) +{ + struct strbuf sb = STRBUF_INIT; + int cur_path_len = strlen(worktree->path); + int path_adj = cur_path_len - utf8_strwidth(worktree->path); + + strbuf_addf(, "%-*s ", 1 + path_maxlen + path_adj, worktree->path); + if (worktree->is_bare) + strbuf_addstr(, "(bare)"); + else { +
Re: [PATCH/RFC 2/2] sha1_file: set packfile to O_CLOEXEC at open
Hi Max, On 2015-10-01 05:29, Max Kirillov wrote: > Windows does not support setting O_CLOEXEC by fcntl, > but there is an open flag O_NOINHERIT which results in same > behaviour. Use it in git_open_noatime() and also bring > setting O_CLOEXEC there also to make it consistent. Rename > the function to git_open_noatime_cloexec(), to avoid confusion. Which problem does this solve? I am actually suspecting that this will rather cause problems because now `exec()`ing children might cause bogus file descriptors to be still held on. So I would recommend to drop this patch. It is not needed to fix the reported bug. Ciao, Dscho -- 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: can't install on OS X
Looks like you have it installed properly. The typical usage is from the terminal, (try `git --version` to be sure). There is also a pretty great UI packaged with git called git-gui. You should be able to make a link or an alias to it in your Applications folder (or invoke it from the terminal `git gui`). On Fri, Oct 2, 2015 at 2:50 AM, Spencer Graveswrote: > What's the procedure for installing Git under OS X 10.11? > > > I downloaded "git-2.5.3-intel-universal-mavericks.dmg" per instructions. > When I tried to install it, I first had trouble because it wasn't from the > Mac App Store nor an "identified developer". I ultimately found "System > Preferences" > "Security & Privacy" > "Click the lock to make changes" > > entered password > AND clicked to "Allow apps downloaded from: Anywhere". > Then the install appeared to run and proclaimed, "The installation was > successful." However, git is not listed under "Applications", and RStudio > says, "Git was not detected on the system path." > > > "README.txt" says I need "sudo mv /usr/bin/git /usr/bin/git-system". I > tried that and got, "mv: rename /usr/bin/git to /usr/bin/git-system: > Operation not permitted" (after entering my password). [My directory now > includes "/usr/local/git", and "/usr/bin" includes git, git-cvsserver, > git-receive-pack, git-shell, git-upload-archive, and git-upload-pack.] > > > Suggestions? Thanks, Spencer Graves > -- > 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 -- 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 41/68] init: use strbufs to store paths
On Fri, Oct 02, 2015 at 08:00:24AM +0200, Torsten Bögershausen wrote: > Peff, are you planing a re-roll ? > Or. Junio, do you plan to fix it ? > Or should I send a patch on top of pu ? I am on vacation, so I am hoping that somebody on OS X can confirm that the patch that I sent earlier does indeed fix it, and that Junio can squash it in. Makefile hack similar to what you posted, but I cannot actually on Linux that the code does what it should). > The compilation can be tested under Linux like this: Yeah, I did something similar to see that it at least compiled, but I don't have an easy way to actually run t3910. -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
Re: [BUG?] applypatch-msg hook no-longer thinks stdin is a tty
Chris Packhamwrites: > As of git 2.6 this has stopped working and stdin always fails the tty > check. We now run that hook thru run_hook_ve(), which closes the standard input (as the hook is not reading anything). Perhaps you can check if your output is connected to the tty instead? -- 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 5/9] ref-filter: adopt get_head_description() from branch.c
Copy the implementation of get_head_description() from branch.c. This gives a description of the HEAD ref if called. This is used as the refname for the HEAD ref whenever the FILTER_REFS_DETACHED_HEAD option is used. Mentored-by: Christian CouderMentored-by: Matthieu Moy Signed-off-by: Karthik Nayak --- builtin/branch.c | 4 ref-filter.c | 38 -- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/builtin/branch.c b/builtin/branch.c index b7a60f4..67ef9f1 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -355,6 +355,10 @@ static void add_verbose_info(struct strbuf *out, struct ref_array_item *item, strbuf_release(); } +/* + * This is duplicated in ref-filter.c, will be removed when we adopt + * ref-filter's printing APIs. + */ static char *get_head_description(void) { struct strbuf desc = STRBUF_INIT; diff --git a/ref-filter.c b/ref-filter.c index 223daeb..15df421 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -13,6 +13,7 @@ #include "utf8.h" #include "git-compat-util.h" #include "version.h" +#include "wt-status.h" typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type; @@ -915,6 +916,37 @@ static inline char *copy_advance(char *dst, const char *src) return dst; } +static char *get_head_description(void) +{ + struct strbuf desc = STRBUF_INIT; + struct wt_status_state state; + memset(, 0, sizeof(state)); + wt_status_get_state(, 1); + if (state.rebase_in_progress || + state.rebase_interactive_in_progress) + strbuf_addf(, _("(no branch, rebasing %s)"), + state.branch); + else if (state.bisect_in_progress) + strbuf_addf(, _("(no branch, bisect started on %s)"), + state.branch); + else if (state.detached_from) { + /* TRANSLATORS: make sure these match _("HEAD detached at ") + and _("HEAD detached from ") in wt-status.c */ + if (state.detached_at) + strbuf_addf(, _("(HEAD detached at %s)"), + state.detached_from); + else + strbuf_addf(, _("(HEAD detached from %s)"), + state.detached_from); + } + else + strbuf_addstr(, _("(no branch)")); + free(state.branch); + free(state.onto); + free(state.detached_from); + return strbuf_detach(, NULL); +} + /* * Parse the object referred by ref, and grab needed value. */ @@ -953,9 +985,11 @@ static void populate_value(struct ref_array_item *ref) name++; } - if (starts_with(name, "refname")) + if (starts_with(name, "refname")) { refname = ref->refname; - else if (starts_with(name, "symref")) + if (ref->kind & FILTER_REFS_DETACHED_HEAD) + refname = get_head_description(); + } else if (starts_with(name, "symref")) refname = ref->symref ? ref->symref : ""; else if (starts_with(name, "upstream")) { const char *branch_name; -- 2.6.0 -- 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/9] port branch.c to use ref-filter printing APIs
This series ports over branch.c to use ref-filter APIs This is the last part of unification of 'git branch -l', 'git tag -l' and 'git for-each-ref'. There are a few topics worth discussing here : 1. [7/9] This ensures that when we use the "%(upstream:track)" atom we print "[gone]" for upstreams which are invalid. We either implement this and try to mimic what branch.c does when we use the verbose option or we can drop this in branch.c. 2. [8/9] The usage of get_format() function in branch.c which provides us the needed format for printing. This seems overly complex to the uninitiated as it uses a complex atom combinations to mimic the existing branch printing format. Karthik Nayak (9): ref-filter: implement %(if), %(then), and %(else) atoms ref-filter: implement %(if:equals=) and %(if:notequals=) ref-filter: add support for %(path) atom ref-filter: modify "%(objectname:short)" to take length ref-filter: adopt get_head_description() from branch.c ref-filter: introduce format_ref_array_item() ref-filter: make %(upstream:track) prints "[gone]" for invalid upstreams branch: use ref-filter printing APIs branch: implement '--format' option Documentation/git-branch.txt | 7 +- Documentation/git-for-each-ref.txt | 32 - builtin/branch.c | 262 ++--- ref-filter.c | 250 +++ ref-filter.h | 3 + t/t3203-branch-output.sh | 11 ++ t/t6040-tracking-info.sh | 12 +- t/t6300-for-each-ref.sh| 24 +++- t/t6302-for-each-ref-filter.sh | 105 +++ 9 files changed, 480 insertions(+), 226 deletions(-) -- 2.6.0 -- 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/9] ref-filter: modify "%(objectname:short)" to take length
Add support for %(objectname:short,) which would print the abbreviated unique objectname of given length. When no length is specified 7 is used. The minimum length is 4. Add tests and documentation for the same. Mentored-by: Christian CouderMentored-by: Matthieu Moy Signed-off-by: Karthik Nayak --- Documentation/git-for-each-ref.txt | 2 ++ ref-filter.c | 39 ++ t/t6300-for-each-ref.sh| 22 + 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt index 6a476ba..5097915 100644 --- a/Documentation/git-for-each-ref.txt +++ b/Documentation/git-for-each-ref.txt @@ -103,6 +103,8 @@ objectsize:: objectname:: The object name (aka SHA-1). For a non-ambiguous abbreviation of the object name append `:short`. + The length can be explicitly specified by appending either + `:short,` or `:,short`. Minimum length is 4. upstream:: The name of a local ref which can be considered ``upstream'' diff --git a/ref-filter.c b/ref-filter.c index b0e86ae..223daeb 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -454,14 +454,37 @@ static void *get_obj(const unsigned char *sha1, struct object **obj, unsigned lo static int grab_objectname(const char *name, const unsigned char *sha1, struct atom_value *v) { - if (!strcmp(name, "objectname")) { - char *s = xmalloc(41); - strcpy(s, sha1_to_hex(sha1)); - v->s = s; - return 1; - } - if (!strcmp(name, "objectname:short")) { - v->s = xstrdup(find_unique_abbrev(sha1, DEFAULT_ABBREV)); + const char *p; + + if (match_atom_name(name, "objectname", )) { + struct strbuf **s, **to_free; + int length = DEFAULT_ABBREV; + + /* No arguments given, copy the entire objectname */ + if (!p) { + char *s = xmalloc(41); + strcpy(s, sha1_to_hex(sha1)); + v->s = s; + } else { + s = to_free = strbuf_split_str(p, ',', 0); + while (*s) { + /* Strip trailing comma */ + if (s[1]) + strbuf_setlen(s[0], s[0]->len - 1); + if (!strtoul_ui(s[0]->buf, 10, (unsigned int *))) + ; + /* The `short` argument uses the default length */ + else if (!strcmp("short", s[0]->buf)) + ; + else + die(_("format: unknown option entered with objectname:%s"), s[0]->buf); + s++; + } + if (length < MINIMUM_ABBREV) + length = MINIMUM_ABBREV; + v->s = xstrdup(find_unique_abbrev(sha1, length)); + free(to_free); + } return 1; } return 0; diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index 7c9bec7..7f675d2 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -385,6 +385,28 @@ test_expect_success 'Check short objectname format' ' test_cmp expected actual ' +cat >expected expected
[PATCH 6/9] ref-filter: introduce format_ref_array_item()
Introduce format_ref_array_item() which will output the details of a given ref_array_item as per the given format and quote_style to the given strbuf. This is derived from show_ref_array_item() which is now reduced to a wrapper around format_ref_array_item(). show_ref_array_item() obtains the strbuf and prints it the standard output. This is needed when we port over the printing options of ref-filter to branch.c. Mentored-by: Christian CouderMentored-by: Matthieu Moy Signed-off-by: Karthik Nayak --- ref-filter.c | 16 ref-filter.h | 3 +++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ref-filter.c b/ref-filter.c index 15df421..099acd6 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -1748,10 +1748,10 @@ static void append_literal(const char *cp, const char *ep, struct ref_formatting } } -void show_ref_array_item(struct ref_array_item *info, const char *format, int quote_style) +void format_ref_array_item(struct ref_array_item *info, const char *format, + int quote_style, struct strbuf *final_buf) { const char *cp, *sp, *ep; - struct strbuf *final_buf; struct ref_formatting_state state = REF_FORMATTING_STATE_INIT; state.quote_style = quote_style; @@ -1781,9 +1781,17 @@ void show_ref_array_item(struct ref_array_item *info, const char *format, int qu } if (state.stack->prev) die(_("format: %%(end) atom missing")); - final_buf = >output; - fwrite(final_buf->buf, 1, final_buf->len, stdout); + strbuf_addbuf(final_buf, >output); pop_stack_element(); +} + +void show_ref_array_item(struct ref_array_item *info, const char *format, int quote_style) +{ + struct strbuf final_buf = STRBUF_INIT; + + format_ref_array_item(info, format, quote_style, _buf); + fwrite(final_buf.buf, 1, final_buf.len, stdout); + strbuf_release(_buf); putchar('\n'); } diff --git a/ref-filter.h b/ref-filter.h index 14d435e..e0b26e8 100644 --- a/ref-filter.h +++ b/ref-filter.h @@ -98,6 +98,9 @@ int parse_ref_filter_atom(const char *atom, const char *ep); int verify_ref_format(const char *format); /* Sort the given ref_array as per the ref_sorting provided */ void ref_array_sort(struct ref_sorting *sort, struct ref_array *array); +/* Based on the given format and quote_style, fill the strbuf */ +void format_ref_array_item(struct ref_array_item *info, const char *format, + int quote_style, struct strbuf *final_buf); /* Print the ref using the given format and quote_style */ void show_ref_array_item(struct ref_array_item *info, const char *format, int quote_style); /* Callback function for parsing the sort option */ -- 2.6.0 -- 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/9] ref-filter: add support for %(path) atom
This adds %(path) and %(path:short) atoms. The %(path) atom will print the path of the given ref, while %(path:short) will only print the subdirectory of the given ref. Add tests and documentation for the same. --- Documentation/git-for-each-ref.txt | 5 + ref-filter.c | 17 + t/t6302-for-each-ref-filter.sh | 39 ++ 3 files changed, 61 insertions(+) diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt index 5c12c2f..6a476ba 100644 --- a/Documentation/git-for-each-ref.txt +++ b/Documentation/git-for-each-ref.txt @@ -145,6 +145,11 @@ if:: compare the value between the %(if:...) and %(then) atoms with the given string. +path:: + The path of the given ref. For a shortened version listing + only the name of the directory the ref is under append + `:short`. + In addition to the above, for commit and tag objects, the header field names (`tree`, `parent`, `object`, `type`, and `tag`) can be used to specify the value in the header field. diff --git a/ref-filter.c b/ref-filter.c index da7723b..b0e86ae 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -58,6 +58,7 @@ static struct { { "if" }, { "then" }, { "else" }, + { "path" }, }; #define REF_FORMATTING_STATE_INIT { 0, NULL } @@ -1042,6 +1043,22 @@ static void populate_value(struct ref_array_item *ref) } else if (!strcmp(name, "else")) { v->handler = else_atom_handler; continue; + } else if (match_atom_name(name, "path", )) { + const char *sp, *ep; + + if (ref->kind & FILTER_REFS_DETACHED_HEAD) + continue; + + sp = strchr(ref->refname, '/'); + ep = strchr(++sp, '/'); + + if (!valp) + sp = ref->refname; + else if (strcmp(valp, "short")) + die(_("format: invalid value given path:%s"), valp); + + v->s = xstrndup(sp, ep - sp); + continue; } else continue; diff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh index d7f7a18..5557657 100755 --- a/t/t6302-for-each-ref-filter.sh +++ b/t/t6302-for-each-ref-filter.sh @@ -312,6 +312,7 @@ test_expect_success 'check %(if:equals=)' ' test_cmp expect actual ' + test_expect_success 'check %(if:notequals=)' ' git for-each-ref --format="%(if:notequals=master)%(refname:short)%(then)Not master%(else)Found master%(end)" refs/heads/ >actual && cat >expect <<-\EOF && @@ -321,4 +322,42 @@ test_expect_success 'check %(if:notequals=)' ' test_cmp expect actual ' +test_expect_success 'check %(path)' ' + git for-each-ref --format="%(path)" >actual && + cat >expect <<-\EOF && + refs/heads + refs/heads + refs/odd + refs/tags + refs/tags + refs/tags + refs/tags + refs/tags + refs/tags + refs/tags + refs/tags + refs/tags + EOF + test_cmp expect actual +' + +test_expect_success 'check %(path:short)' ' + git for-each-ref --format="%(path:short)" >actual && + cat >expect <<-\EOF && + heads + heads + odd + tags + tags + tags + tags + tags + tags + tags + tags + tags + EOF + test_cmp expect actual +' + test_done -- 2.6.0 -- 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/9] ref-filter: implement %(if:equals=) and %(if:notequals=)
Implement %(if:equals=) wherein the if condition is only satisfied if the value obtained between the %(if:...) and %(then) atom is the same as the given ''. Similarly, implement (if:notequals=) wherein the if condition is only satisfied if the value obtained between the %(if:...) and %(then) atom is differnt from the given ''. Add tests and Documentation for the same. Mentored-by: Christian CouderMentored-by: Matthieu Moy Signed-off-by: Karthik Nayak --- Documentation/git-for-each-ref.txt | 4 +++- ref-filter.c | 28 t/t6302-for-each-ref-filter.sh | 18 ++ 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt index 768a512..5c12c2f 100644 --- a/Documentation/git-for-each-ref.txt +++ b/Documentation/git-for-each-ref.txt @@ -141,7 +141,9 @@ if:: If there is an atom with value or string literal after the %(if) then everything after the %(then) is printed, else if the %(else) atom is used, then everything after %(else) is - printed. + printed. Append ":equals=" or ":notequals=" to + compare the value between the %(if:...) and %(then) atoms with the + given string. In addition to the above, for commit and tag objects, the header field names (`tree`, `parent`, `object`, `type`, and `tag`) can diff --git a/ref-filter.c b/ref-filter.c index 93b07f5..da7723b 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -73,6 +73,8 @@ struct contents { }; struct if_then_else { + const char *if_equals, + *not_equals; unsigned int if_atom : 1, then_atom : 1, else_atom : 1, @@ -277,8 +279,16 @@ static void if_atom_handler(struct atom_value *atomv, struct ref_formatting_stat { struct ref_formatting_stack *new; struct if_then_else *if_then_else = xcalloc(sizeof(struct if_then_else), 1); + const char *valp; if_then_else->if_atom = 1; + if (skip_prefix(atomv->s, "equals=", )) + if_then_else->if_equals = valp; + else if (skip_prefix(atomv->s, "notequals=", )) + if_then_else->not_equals = valp; + else if (atomv->s[0]) + die(_("format: unknown format if:%s"), atomv->s); + push_stack_element(>stack); new = state->stack; new->at_end = if_then_else_handler; @@ -302,11 +312,19 @@ static void then_atom_handler(struct atom_value *atomv, struct ref_formatting_st if (!if_then_else) die(_("format: %%(then) atom used without an %%(if) atom")); if_then_else->then_atom = 1; + /* -* If there exists non-empty string between the 'if' and -* 'then' atom then the 'if' condition is satisfied. +* If the 'equals' or 'notequals' attribute is used then +* perform the required comparison. If not, only non-empty +* strings satisfy the 'if' condition. */ - if (cur->output.len && !is_empty(cur->output.buf)) + if (if_then_else->if_equals) { + if (!strcmp(if_then_else->if_equals, cur->output.buf)) + if_then_else->condition_satisfied = 1; + } else if (if_then_else->not_equals) { + if (strcmp(if_then_else->not_equals, cur->output.buf)) + if_then_else->condition_satisfied = 1; + } else if (cur->output.len && !is_empty(cur->output.buf)) if_then_else->condition_satisfied = 1; strbuf_reset(>output); } @@ -1013,8 +1031,10 @@ static void populate_value(struct ref_array_item *ref) } else if (!strcmp(name, "end")) { v->handler = end_atom_handler; continue; - } else if (!strcmp(name, "if")) { + } else if (match_atom_name(name, "if", )) { v->handler = if_atom_handler; + if (valp) + v->s = xstrdup(valp); continue; } else if (!strcmp(name, "then")) { v->handler = then_atom_handler; diff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh index 7ce1cc4..d7f7a18 100755 --- a/t/t6302-for-each-ref-filter.sh +++ b/t/t6302-for-each-ref-filter.sh @@ -303,4 +303,22 @@ test_expect_success 'check %(if)...%(then)...%(else)...%(end) atoms' ' test_cmp expect actual ' +test_expect_success 'check %(if:equals=)' ' + git for-each-ref --format="%(if:equals=master)%(refname:short)%(then)Found master%(else)Not master%(end)" refs/heads/ >actual && + cat >expect <<-\EOF && + Found master + Not master + EOF + test_cmp expect actual +' + +test_expect_success 'check %(if:notequals=)' ' + git for-each-ref
Re: [RFC/PATCH v1] Add Travis CI support
On 25.09.2015 05:14, Dennis Kaarsemaker wrote: My idea is that the owner of "https://github.com/git/git; enables this account for Travis (it's free!). Then we would automatically get the test state for all official branches. The last time I heard about this "it's free" thing, I thought I heard that it wants write access to the repository. It does not need write access to the git data, only to auxiliary GitHub data: commit status and deployment status (where it can put "this commit failed tests"), repository hooks (to set up build triggers), team membership (ro) and email addresses (ro). Also, as Roberto explained at [1], "If you set up the webhook yourself, you don't need to grant the [repository hooks] permissions". BTW, there's already an attempt at creating a .travis.yml file at [2]. [1] https://github.com/rtyley/submitgit/issues/16#issuecomment-120119634 [2] https://github.com/git/git/pull/154 -- Sebastian Schuberth -- 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: [BUG?] applypatch-msg hook no-longer thinks stdin is a tty
Junio C Hamanowrites: > Chris Packham writes: > >> As of git 2.6 this has stopped working and stdin always fails the tty >> check. > > We now run that hook thru run_hook_ve(), which closes the standard > input (as the hook is not reading anything). Perhaps you can check > if your output is connected to the tty instead? s|closes the standard input|opens the standard input for /dev/null|; Having said that, here are some further thoughts: * Hooks run via run_hook_ve() and run_hook_le() have their standard input connected to /dev/null even before these functions were introduced at ae98a008 (Move run_hook() from builtin-commit.c into run-command.c (libgit), 2009-01-16). The commit consolidated the code to run hooks in "checkout", "commit", "gc", and "merge", all of which run their hooks with their standard input reading from /dev/null. * Later at dfa7a6c5 (clone: run post-checkout hook when checking out, 2009-03-03) "git clone" learned to run post-checkout hook the same way. * "receive-pack" (which accepts and processes an incoming "git push") has pre-receive and post-receive hooks, and they do get invoked with their standard input open, but they are connected to a pipe to be fed with the information about the push from "receive-pack" process. * "post-rewrite" hooks, invoked by "rebase" and "commit", does get invoked with its standard input open, but it is fed with the information about the original and the rewritten commit. So in that sense, "am", primarily because it was implemented as a script, was an oddball. It should have been connecting the standard input to /dev/null in order to be consistent with others, but it did not even bother to do so. We _could_ leave the standard input connected to the original process's standard input only for the specific hook by doing something along the lines of the attached, but I am not sure if it is a good change. Given that the majority of existing hooks are spawned with their standard input connected to /dev/null (and also after scanning the output from "git hooks --help", I did not find any that would want to read from the standard input of the original process that spawns it), I tend to consider that the change in 2.6 done as part of rewriting "am" in C is a bugfix, even though an unintended one, to make things more consistent. Besides "consistency", a hook that tried to read from "am"'s standard input would have been incorrect in the first place, as it is a normal mode of operation to feed one or more patch e-mails from the standard input of "git am", i.e. $ git am msg); - ret = run_hook_le(NULL, "applypatch-msg", am_path(state, "final-commit"), NULL); + + custom.env = NULL; + custom.no_stdin = 0; + custom.stdout_to_stderr = 1; + + ret = run_hook_le_opt(, "applypatch-msg", am_path(state, "final-commit"), NULL); if (!ret) { free(state->msg); diff --git a/run-command.c b/run-command.c index 3277cf7..dee86df 100644 --- a/run-command.c +++ b/run-command.c @@ -793,7 +793,7 @@ const char *find_hook(const char *name) return path.buf; } -int run_hook_ve(const char *const *env, const char *name, va_list args) +int run_hook_ve_opt(struct child_process *custom, const char *name, va_list args) { struct child_process hook = CHILD_PROCESS_INIT; const char *p; @@ -805,13 +805,35 @@ int run_hook_ve(const char *const *env, const char *name, va_list args) argv_array_push(, p); while ((p = va_arg(args, const char *))) argv_array_push(, p); - hook.env = env; - hook.no_stdin = 1; - hook.stdout_to_stderr = 1; + hook.env = custom->env; + hook.no_stdin = custom->no_stdin; + hook.stdout_to_stderr = custom->stdout_to_stderr; return run_command(); } +int run_hook_ve(const char *const *env, const char *name, va_list args) +{ + struct child_process custom = CHILD_PROCESS_INIT; + + custom.env = env; + custom.no_stdin = 1; + custom.stdout_to_stderr = 1; + return run_hook_ve_opt(, name, args); +} + +int run_hook_le_opt(struct child_process *custom, const char *name, ...) +{ + va_list args; + int ret; + + va_start(args, name); + ret = run_hook_ve_opt(custom, name, args); + va_end(args); + + return ret; +} + int run_hook_le(const char *const *env, const char *name, ...) { va_list args; diff --git a/run-command.h b/run-command.h index 5b4425a..33a0d72 100644 --- a/run-command.h +++ b/run-command.h @@ -62,6 +62,15 @@ LAST_ARG_MUST_BE_NULL extern int run_hook_le(const char *const *env, const char *name, ...); extern int run_hook_ve(const char *const *env, const char *name, va_list args); +/* + * Same as above, but env, no_stdin and stdout_to_stderr are copied from + * custom to the child_process structure that spawns the hook. + */
Re: [PATCH] submodule-parallel-fetch: make some file local symbols static
Ramsay Joneswrites: >> I thought I had this in yesterdays reroll (v6). Oh you're referring to >> the version >> from the 28th (I forgot to label them v5 I suppose). > > Ah! I thought I'd seen it on the list. (I thought I was going crazy) ;-) > Sorry, my fault. I just assumed that today's pu branch would have your > latest patches - I didn't actually check that. Sometimes I take a one-day vacation ;-) Thanks. -- 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 8/9] branch: use ref-filter printing APIs
Port branch.c to use ref-filter APIs for printing. This clears out most of the code used in branch.c for printing and replaces them with calls made to the ref-filter library. Introduce get_format() which gets the format required for printing of refs. Make amendments to print_ref_list() to reflect these changes. Since branch.c is being ported to use ref-filter APIs to print the required data, it is constricted to the constraints of printing as per ref-filter. Which means branch.c can only print as per the atoms available in ref-filter. Hence the "-vv" option of 'git branch' now prints the upstream and its tracking details separately as "[] []" instead of "[: ]". Make changes in /t/t6040-tracking-info.sh to reflect the change. Mentored-by: Christian CouderMentored-by: Matthieu Moy Signed-off-by: Karthik Nayak --- builtin/branch.c | 258 --- t/t6040-tracking-info.sh | 12 +-- 2 files changed, 69 insertions(+), 201 deletions(-) diff --git a/builtin/branch.c b/builtin/branch.c index 67ef9f1..48fbca1 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -35,12 +35,12 @@ static unsigned char head_sha1[20]; static int branch_use_color = -1; static char branch_colors[][COLOR_MAXLEN] = { - GIT_COLOR_RESET, - GIT_COLOR_NORMAL, /* PLAIN */ - GIT_COLOR_RED, /* REMOTE */ - GIT_COLOR_NORMAL, /* LOCAL */ - GIT_COLOR_GREEN,/* CURRENT */ - GIT_COLOR_BLUE, /* UPSTREAM */ + "%(color:reset)", + "%(color:reset)", /* PLAIN */ + "%(color:red)", /* REMOTE */ + "%(color:reset)", /* LOCAL */ + "%(color:green)", /* CURRENT */ + "%(color:blue)",/* UPSTREAM */ }; enum color_branch { BRANCH_COLOR_RESET = 0, @@ -271,192 +271,6 @@ static int delete_branches(int argc, const char **argv, int force, int kinds, return(ret); } -static void fill_tracking_info(struct strbuf *stat, const char *branch_name, - int show_upstream_ref) -{ - int ours, theirs; - char *ref = NULL; - struct branch *branch = branch_get(branch_name); - const char *upstream; - struct strbuf fancy = STRBUF_INIT; - int upstream_is_gone = 0; - int added_decoration = 1; - - if (stat_tracking_info(branch, , , ) < 0) { - if (!upstream) - return; - upstream_is_gone = 1; - } - - if (show_upstream_ref) { - ref = shorten_unambiguous_ref(upstream, 0); - if (want_color(branch_use_color)) - strbuf_addf(, "%s%s%s", - branch_get_color(BRANCH_COLOR_UPSTREAM), - ref, branch_get_color(BRANCH_COLOR_RESET)); - else - strbuf_addstr(, ref); - } - - if (upstream_is_gone) { - if (show_upstream_ref) - strbuf_addf(stat, _("[%s: gone]"), fancy.buf); - else - added_decoration = 0; - } else if (!ours && !theirs) { - if (show_upstream_ref) - strbuf_addf(stat, _("[%s]"), fancy.buf); - else - added_decoration = 0; - } else if (!ours) { - if (show_upstream_ref) - strbuf_addf(stat, _("[%s: behind %d]"), fancy.buf, theirs); - else - strbuf_addf(stat, _("[behind %d]"), theirs); - - } else if (!theirs) { - if (show_upstream_ref) - strbuf_addf(stat, _("[%s: ahead %d]"), fancy.buf, ours); - else - strbuf_addf(stat, _("[ahead %d]"), ours); - } else { - if (show_upstream_ref) - strbuf_addf(stat, _("[%s: ahead %d, behind %d]"), - fancy.buf, ours, theirs); - else - strbuf_addf(stat, _("[ahead %d, behind %d]"), - ours, theirs); - } - strbuf_release(); - if (added_decoration) - strbuf_addch(stat, ' '); - free(ref); -} - -static void add_verbose_info(struct strbuf *out, struct ref_array_item *item, -struct ref_filter *filter, const char *refname) -{ - struct strbuf subject = STRBUF_INIT, stat = STRBUF_INIT; - const char *sub = _(" invalid ref "); - struct commit *commit = item->commit; - - if (!parse_commit(commit)) { - pp_commit_easy(CMIT_FMT_ONELINE, commit, ); - sub = subject.buf; - } - - if (item->kind == FILTER_REFS_BRANCHES) - fill_tracking_info(, refname, filter->verbose > 1); - - strbuf_addf(out, " %s %s%s",
[PATCH 1/9] ref-filter: implement %(if), %(then), and %(else) atoms
Implement %(if), %(then) and %(else) atoms. Used as %(if)..%(then)..%(end) or %(if)..%(then)..%(else)..%(end). If there is an atom with value or string literal after the %(if) then everything after the %(then) is printed, else if the %(else) atom is used, then everything after %(else) is printed. If the string contains only whitespaces, then it is not considered. Nesting of this construct is possible. This is in preperation for porting over `git branch -l` to use ref-filter APIs for printing. Add Documentation and tests regarding the same. Mentored-by: Christian CouderMentored-by: Matthieu Moy Signed-off-by: Karthik Nayak --- Documentation/git-for-each-ref.txt | 23 +++- ref-filter.c | 116 ++--- t/t6302-for-each-ref-filter.sh | 48 +++ 3 files changed, 177 insertions(+), 10 deletions(-) diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt index 16b4ac5..768a512 100644 --- a/Documentation/git-for-each-ref.txt +++ b/Documentation/git-for-each-ref.txt @@ -134,9 +134,14 @@ align:: `` is either left, right or middle, default being left and `` is the total length of the content with alignment. If the contents length is more than the width then - no alignment is performed. If used with '--quote' everything - in between %(align:...) and %(end) is quoted, but if nested - then only the topmost level performs quoting. + no alignment is performed. + +if:: + Used as %(if)..%(then)..(%end) or %(if)..%(then)..%(else)..%(end). + If there is an atom with value or string literal after the + %(if) then everything after the %(then) is printed, else if + the %(else) atom is used, then everything after %(else) is + printed. In addition to the above, for commit and tag objects, the header field names (`tree`, `parent`, `object`, `type`, and `tag`) can @@ -169,6 +174,18 @@ the date by adding one of `:default`, `:relative`, `:short`, `:local`, `:iso8601`, `:rfc2822` or `:raw` to the end of the fieldname; e.g. `%(taggerdate:relative)`. +Some atoms like %(align) and %(if) always require a matching %(end). +We call them "opening atoms" and sometimes denote them as %($open). + +When a scripting language specific quoting is in effect, except for +opening atoms, replacement from every %(atom) is quoted when and only +when it appears at the top-level (that is, when it appears outside +%($open)...%(end)). + +When a scripting language specific quoting is in effect, everything +between a top-level opening atom and its matching %(end) is evaluated +according to the semantics of the opening atom and its result is +quoted. EXAMPLES diff --git a/ref-filter.c b/ref-filter.c index dbd8fce..93b07f5 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -55,6 +55,9 @@ static struct { { "color" }, { "align" }, { "end" }, + { "if" }, + { "then" }, + { "else" }, }; #define REF_FORMATTING_STATE_INIT { 0, NULL } @@ -69,10 +72,17 @@ struct contents { struct object_id oid; }; +struct if_then_else { + unsigned int if_atom : 1, + then_atom : 1, + else_atom : 1, + condition_satisfied : 1; +}; + struct ref_formatting_stack { struct ref_formatting_stack *prev; struct strbuf output; - void (*at_end)(struct ref_formatting_stack *stack); + void (*at_end)(struct ref_formatting_stack **stack); void *at_end_data; }; @@ -216,13 +226,14 @@ static void pop_stack_element(struct ref_formatting_stack **stack) *stack = prev; } -static void end_align_handler(struct ref_formatting_stack *stack) +static void end_align_handler(struct ref_formatting_stack **stack) { - struct align *align = (struct align *)stack->at_end_data; + struct ref_formatting_stack *cur = *stack; + struct align *align = (struct align *)cur->at_end_data; struct strbuf s = STRBUF_INIT; - strbuf_utf8_align(, align->position, align->width, stack->output.buf); - strbuf_swap(>output, ); + strbuf_utf8_align(, align->position, align->width, cur->output.buf); + strbuf_swap(>output, ); strbuf_release(); } @@ -236,6 +247,85 @@ static void align_atom_handler(struct atom_value *atomv, struct ref_formatting_s new->at_end_data = >u.align; } +static void if_then_else_handler(struct ref_formatting_stack **stack) +{ + struct ref_formatting_stack *cur = *stack; + struct ref_formatting_stack *prev = cur->prev; + struct if_then_else *if_then_else = (struct if_then_else *)cur->at_end_data; + + /* +* If the 'if' condition is satisfied, then if there exists an +* 'else' atom drop the 'else' atom's state. Else we swap the +* buffer of the 'else' atom with the
[PATCH 9/9] branch: implement '--format' option
Implement the '--format' option provided by 'ref-filter'. This lets the user list tags as per desired format similar to the implementation in 'git for-each-ref'. Add tests and documentation for the same. Mentored-by: Christian CouderMentored-by: Matthieu Moy Signed-off-by: Karthik Nayak --- Documentation/git-branch.txt | 7 ++- builtin/branch.c | 14 +- t/t3203-branch-output.sh | 11 +++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 03c7af1..5227206 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -12,7 +12,7 @@ SYNOPSIS [--list] [-v [--abbrev= | --no-abbrev]] [--column[=] | --no-column] [(--merged | --no-merged | --contains) []] [--sort=] - [--points-at ] [...] + [--points-at ] [--format=] [...] 'git branch' [--set-upstream | --track | --no-track] [-l] [-f] [] 'git branch' (--set-upstream-to= | -u ) [] 'git branch' --unset-upstream [] @@ -244,6 +244,11 @@ start-point is either a local or remote-tracking branch. --points-at :: Only list branches of the given object. +--format :: + A string that interpolates `%(fieldname)` from the object + pointed at by a ref being shown. The format is the same as + that of linkgit:git-for-each-ref[1]. + Examples diff --git a/builtin/branch.c b/builtin/branch.c index 48fbca1..ae3ecfb 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -27,6 +27,7 @@ static const char * const builtin_branch_usage[] = { N_("git branch [] [-r] (-d | -D) ..."), N_("git branch [] (-m | -M) [] "), N_("git branch [] [-r | -a] [--points-at]"), + N_("git branch [] [-r | -a] [--format]"), NULL }; @@ -331,14 +332,14 @@ static char *get_format(struct ref_filter *filter, int maxwidth, const char *rem return final; } -static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sorting) +static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sorting, const char *format) { int i; struct ref_array array; int maxwidth = 0; const char *remote_prefix = ""; struct strbuf out = STRBUF_INIT; - char *format; + char *to_free = NULL; /* * If we are listing more than just remote branches, @@ -355,7 +356,8 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin if (filter->verbose) maxwidth = calc_maxwidth(, strlen(remote_prefix)); - format = get_format(filter, maxwidth, remote_prefix); + if (!format) + format = to_free = get_format(filter, maxwidth, remote_prefix); verify_ref_format(format); /* @@ -382,7 +384,7 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin } ref_array_clear(); - free(format); + free(to_free); } static void rename_branch(const char *oldname, const char *newname, int force) @@ -483,6 +485,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) enum branch_track track; struct ref_filter filter; static struct ref_sorting *sorting = NULL, **sorting_tail = + const char *format = NULL; struct option options[] = { OPT_GROUP(N_("Generic options")), @@ -523,6 +526,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) OPTION_CALLBACK, 0, "points-at", _at, N_("object"), N_("print only branches of the object"), 0, parse_opt_object_name }, + OPT_STRING( 0 , "format", , N_("format"), N_("format to use for the output")), OPT_END(), }; @@ -581,7 +585,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) if ((filter.kind & FILTER_REFS_BRANCHES) && filter.detached) filter.kind |= FILTER_REFS_DETACHED_HEAD; filter.name_patterns = argv; - print_ref_list(, sorting); + print_ref_list(, sorting, format); print_columns(, colopts, NULL); string_list_clear(, 0); return 0; diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh index f1ae5ff..a475ff1 100755 --- a/t/t3203-branch-output.sh +++ b/t/t3203-branch-output.sh @@ -163,4 +163,15 @@ test_expect_success 'git branch --points-at option' ' test_cmp expect actual ' +test_expect_success 'git branch --format option' ' + cat >expect <<-\EOF && + Refname is (HEAD detached from fromtag) + Refname is refs/heads/branch-one + Refname is refs/heads/branch-two + Refname is refs/heads/master + EOF + git branch --format="Refname is
Re: Question - List current hashs of branches
for-each-ref & ls-remote? On Fri, Oct 2, 2015 at 11:54 AM, Golarits, Zsigmond (Nokia - HU/Budapest)wrote: > Hello, > > How can I get the current commit-hashes of the remote and local branches > without check them out? > > Br, > Zsigmond Golarits > -- > 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 -- 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 v9 5/5] worktree: add 'list' command
Michael Rappazzowrites: > + if (!porcelain) { > + for (i = 0; worktrees[i]; i++) { > + int path_len = strlen(worktrees[i]->path); > + if (path_len > path_maxlen) > + path_maxlen = path_len; > + int sha1_len = strlen( > + > find_unique_abbrev(worktrees[i]->head_sha1, DEFAULT_ABBREV)); decl-after-stmt. If I were doing this, I'd probably do something like the attached using a small helper function to make the primary logic easier to see. The first hunk below is unrelated but was to fix an obvious style breakage I happened to have noticed nearby. Thanks. builtin/worktree.c | 40 +++- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/builtin/worktree.c b/builtin/worktree.c index 268f9bf..3be8ec8 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -376,8 +376,8 @@ static void show_worktree_porcelain(struct worktree *worktree) } printf("\n"); } -static void show_worktree( - struct worktree *worktree, int path_maxlen, int abbrev_len) + +static void show_worktree(struct worktree *worktree, int path_maxlen, int abbrev_len) { struct strbuf sb = STRBUF_INIT; int cur_path_len = strlen(worktree->path); @@ -399,6 +399,22 @@ static void show_worktree( strbuf_release(); } +static void measure_widths(struct worktree **wt, int *abbrev, int *maxlen) +{ + int i; + + for (i = 0; wt[i]; i++) { + int sha1_len; + int path_len = strlen(wt[i]->path); + + if (path_len > *maxlen) + *maxlen = path_len; + sha1_len = strlen(find_unique_abbrev(wt[i]->head_sha1, *abbrev)); + if (sha1_len > *abbrev) + *abbrev = sha1_len; + } +} + static int list(int ac, const char **av, const char *prefix) { int porcelain = 0; @@ -413,21 +429,11 @@ static int list(int ac, const char **av, const char *prefix) usage_with_options(worktree_usage, options); else { struct worktree **worktrees = get_worktrees(); - int path_maxlen = 0; - int abbrev = 0; - int i; - - if (!porcelain) { - for (i = 0; worktrees[i]; i++) { - int path_len = strlen(worktrees[i]->path); - if (path_len > path_maxlen) - path_maxlen = path_len; - int sha1_len = strlen( - find_unique_abbrev(worktrees[i]->head_sha1, DEFAULT_ABBREV)); - if (sha1_len > abbrev) - abbrev = sha1_len; - } - } + int path_maxlen = 0, abbrev = DEFAULT_ABBREV, i; + + if (!porcelain) + measure_widths(worktrees, , _maxlen); + for (i = 0; worktrees[i]; i++) { if (porcelain) show_worktree_porcelain(worktrees[i]); -- 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
Question - List current hashs of branches
Hello, How can I get the current commit-hashes of the remote and local branches without check them out? Br, Zsigmond Golarits -- 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/RFC 1/2] sha1_file: close all pack files after running
On Fri, Oct 02, 2015 at 12:05:55PM +0200, Johannes Schindelin wrote: > Hi Max, > > On 2015-10-01 05:29, Max Kirillov wrote: >> When a builtin has done its job, but waits for pager or not waited >> by its caller and still hanging it keeps pack files opened. >> This can cause a number of issues, for example on Windows git gc >> cannot remove the packs. > > I did not experience that issue. In any case, closing the > packs after the builtin function has returned might not > change anything anyway because we are about to `exit()` > and that's that. Steps to reproduce: 1. install the latest git-for-windows, 2.6.0.windows.1 2. run the script in the end of message 3. remember the directory name, press the enter as it asks 4. in the less scrool down Then inspect the processes git.exe and less.exe with Process Explorer of something you find convenient. Both processes should have opened the pack file, and git.exe should have it mapped (I found it in the "View"->"Lower Pane views"->"Dlls"). Then, if you run another bash window, cd to the repository and run "git repack -a -d", it should print: $ git repack -a -d Counting objects: 3001, done. Compressing objects: 100% (1003/1003), done. Writing objects: 100% (3001/3001), done. Total 3001 (delta 997), reused 3001 (delta 997) Unlink of file '.git/objects/pack/pack-e1b0e3ac01ff8d79a77648de3370f49b93c58a8b.pack' failed. Should I try again? (y/n) I would like the git gc to succeed, because I run it as a scheduled task nightly and feel a bit annoyed by the opened windows which wait for me to say yes (after exiting pager). So, the fix is needed approximately in that place, after running any builtin command. For your case, I think, the same close_all_packs() should be invoked before the repacking. > The convention in Git seems to call things _gently rather > than _nodie: Thanks, will change it if the idea is welcomed. >> -void close_pack_windows(struct packed_git *p) >> +static int close_pack_windows_nodie(struct packed_git *p) >> { >> while (p->windows) { >> struct pack_window *w = p->windows; >> >> if (w->inuse_cnt) >> -die("pack '%s' still has open windows to it", >> -p->pack_name); >> +return 1; >> + >> munmap(w->base, w->len); >> pack_mapped -= w->len; >> pack_open_windows--; >> p->windows = w->next; >> free(w); >> } >> + >> +return 0; >> +} > > And while we're at it, why not teach that function a new > parameter `int close_pack_fd`? I think "close windows" should close windows, if it also closes pack fd probably should be another name. But current code seems quite logical. Close the packs, and run closing windows from it. > There is another problem: when we cannot close the pack > window, we cannot really continue, can we? Yes we can, unlocking of the window is not needed for the current process to do what it intended to do, it would just interfere with concurrent git gc. For the clone case probably die would be appropriate. If you feel like it worth complicating the code we might search for some solution. -- Max The script: - ./t-windows-pack-close.sh - #!/bin/sh set -e TEST_DIR=`mktemp -d` t_git() { git --work-tree="$TEST_DIR" --git-dir="$TEST_DIR/.git" "$@" } t_git init for i in $(seq 1000) do echo "commit$i" >"$TEST_DIR/commit.$i" t_git add "commit.$i" t_git commit -m "commit$i" -q done t_git repack pack_path=$(find "$TEST_DIR/.git/objects/pack" -name "pack-.pack") echo "dir: $TEST_DIR" echo press enter to start git log read t_git -c core.packedGitWindowSize=100 log - -- 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/RFC 1/2] sha1_file: close all pack files after running
On Fri, Oct 02, 2015 at 12:13:40PM +0200, Johannes Schindelin wrote: > Hi Max, > > On 2015-10-02 12:05, Johannes Schindelin wrote: > > > On 2015-10-01 05:29, Max Kirillov wrote: >>> When a builtin has done its job, but waits for pager or not waited >>> by its caller and still hanging it keeps pack files opened. >>> This can cause a number of issues, for example on Windows git gc >>> cannot remove the packs. > > Could you do me another favor? It seems that you want to > work on this, so I will step back (I have to take off for > the weekend very soon anyway, so I am really glad that you > take care of it). But I would really love to see the line As I explained in other message, your case is a bit different. I could add another call of close_all_packs() as a separate commit with the "fixes" link, but I'm not so sure about it if it turns out that additional efforts are required. -- Max -- 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: [PATCHv6 0/8] fetch submodules in parallel
Stefan Bellerwrites: > * renamed return_value_fn to task_finished_fn It made interdiff noisier but I think it gives us a good end result. > * the main loop of the parallel processing was first adapted to Junios > suggestion, > but Jonathan pointed out more improvements. We can get rid of > `no_more_task` > completely as `if (!pp->nr_processes)` as the exit condition is sufficient. > (pp->nr_processes is modified only when starting or reaping a child, so we > will > capture the whole output of each subprocess even in case of a quick > shutdown) Interesting. The original motivation for "no-more-task" check was that even when we are no longer running anything (i.e. everybody finished) we may get a new task from next_task(), and the condition to "break" out of the loop could be placed anywhere in that loop (e.g. after we wait and cull the finished tasks, or even in the outermost while(1) condition). But you can take advantage of the specific placement of the check; it is after the part that spawns new tasks and before the part that culls the existing tasks, so not having any running task at that point is sufficient condition. Will replace what was queued. Thanks. -- 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: can't install on OS X
On 10/2/2015 8:41 AM, Stephen Bash wrote: - Original Message - From: "Spencer Graves"Sent: Friday, October 2, 2015 2:50:30 AM Subject: can't install on OS X I downloaded "git-2.5.3-intel-universal-mavericks.dmg" per instructions. When I tried to install it, I first had trouble because it wasn't from the Mac App Store nor an "identified developer". You can also right click on the installer and select "Open" for a very similar dialog, but one that gives you the opportunity to run the installer anyway. "README.txt" says I need "sudo mv /usr/bin/git /usr/bin/git-system". I tried that and got, "mv: rename /usr/bin/git to /usr/bin/git-system: Operation not permitted" (after entering my password). [My directory now includes "/usr/local/git", and "/usr/bin" includes git, git-cvsserver, git-receive-pack, git-shell, git-upload-archive, and git-upload-pack.] Suggestions? Sounds like you're running afoul of El Capitan's new System Integrity Protection (SIP) [1]. The git commands you're seeing there are probably Apple's thin wrappers that are mostly meant to provide instructions on installing XCode, but SIP is stopping you from modifying the /usr directory (ah, Apple's Infinite Wisdom). There are discussions about working around SIP in the Apple forums [2] and Homebrew has some hints as well [3]. [1] https://developer.apple.com/library/prerelease/mac/releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_11.html [2] https://forums.developer.apple.com/thread/3981 [3] https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/El_Capitan_and_Homebrew.md#if-usrlocal-does-not-exist Thanks. That helped. I will summarize here what seemed to work for me (skipping the wailing, gnashing of teeth, Apple tech support, etc.): [step 1] download and install "git-2.5.3-intel-universal-mavericks.dmg" as normal, ending with "Install successful". Confirm that git is still not properly installed. Shut down or restart. [step 2] Boot into the Recovery partition by holding down +R while power on and boot. [step 3] Utilities > Terminal [step 4] $ scrutil disable [step 5] Restart normally > Terminal > sudo mv /usr/git /usr/bin/git-system [step 6] Shut down and reboot into the Recovery partition as above. [step 7] Utilities > Terminal [step 8] $ scrutil enable [step 9] Restart normally ... *** Git now seems to be installed. I'm still having trouble getting it to work properly with a private GitHub repository. However, RStudio recognizes git, and I've confirmed that /usr/bin includes a subdirectory git-system and NOT simply git. My problems now seem to be GitHub and RStudio issues. Thanks again for your help. I hope this summary might help others. Spencer Graves HTH, Stephen -- 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/RFC 1/2] sha1_file: close all pack files after running
On Fri, Oct 02, 2015 at 10:06:46PM +0300, Max Kirillov wrote: > for i in $(seq 1000) > t_git -c core.packedGitWindowSize=100 log It was 32-bit build. I cannot promise those exactly numbers will work, because I don not clearly understand what do they mean. With 100 commits the pack size was 20K, but it was mapped fully with the window=100. But I believe with the same build same numbers should reproduce the issue. For 32-bit builds I can see it on any significantly big repository, like the git itself. Maybe for 64bit it is less likely. The code which decides whether to close the pack is in use_pack() in sha1_file.c: --- if (!win->offset && win->len == p->pack_size && !p->do_not_close) { close(p->pack_fd); pack_open_fds--; p->pack_fd = -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
Re: [PATCH 1/9] ref-filter: implement %(if), %(then), and %(else) atoms
Karthik Nayakwrites: > +static int is_empty(const char * s){ > + while (*s != '\0') { > + if (!isspace(*s)) > + return 0; > + s++; > + } > + return 1; > +} My knee-jerk reaction was "why is space so special?", but if a caller really cared, it can do "%(if:not_equal=)%(something)%(then)" to unignore spaces in %(something), so it is not a huge deal. It may be that ignoring spaces when checking if something is empty is so common that this default is useful---I cannot tell offhand. > +if:: > + Used as %(if)..%(then)..(%end) or %(if)..%(then)..%(else)..%(end). > + If there is an atom with value or string literal after the > + %(if) then everything after the %(then) is printed, else if > + the %(else) atom is used, then everything after %(else) is > + printed. I notice that "we ignore space when evaluating the string before %(then)" is not mentioned here. That fact, and an example or two that illustrates the situation where this "ignore spaces" behaviour is useful, would be a good thing to document here. Thanks. -- 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 27/43] refs.c: move should_autocreate_reflog to common code
Up to this step everything looked sensible. Thanks. -- 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 42/43] refs: add LMDB refs backend
David Turnerwrites: > diff --git a/refs-be-lmdb.c b/refs-be-lmdb.c > new file mode 100644 > index 000..99cbd29 > --- /dev/null > +++ b/refs-be-lmdb.c > @@ -0,0 +1,2003 @@ > +/* > + ... > + */ > +#include > +#include > +#include "cache.h" "git-compat-util.h" (or "cache.h", because it is well known and includes "git-compat-util.h" as the first thing before doing anything else) must be the first file included in any of our C files, unless it is a platform specific compat/ object. -- 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 4/9] ref-filter: modify "%(objectname:short)" to take length
Karthik Nayakwrites: > Add support for %(objectname:short,) which would print the > abbreviated unique objectname of given length. When no length is > specified 7 is used. The minimum length is 4. It would have to be "short=", not "short,", if I recall the previous discussion on width=, etc., on the %(align) atom. -- 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 2/9] ref-filter: implement %(if:equals=) and %(if:notequals=)
Karthik Nayakwrites: > Implement %(if:equals=) wherein the if condition is only > satisfied if the value obtained between the %(if:...) and %(then) atom > is the same as the given ''. > > Similarly, implement (if:notequals=) wherein the if condition > is only satisfied if the value obtained between the %(if:...) and > %(then) atom is differnt from the given ''. > > Add tests and Documentation for the same. > > Mentored-by: Christian Couder > Mentored-by: Matthieu Moy > Signed-off-by: Karthik Nayak > --- The fast that the patch touches only the narrow parts that are specific to %(if),%(then) and %(else) and does not have to touch any generic part (other than the populate_value() parser for obvious reasons) is a good signal that tells us that the basic structure of the code is very sound. I very much like the direction in which this series is going ;-) -- 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 feature request: mark a commit as minor
A minor change (also called "cosmetic") usually is a typo fix, doc improvement, a little code refactoring that don't change the behavior etc. In Wikipedia we can mark an edition as "minor". It would be nice to have an argument like "--minor" in git-commit to mark the commit as minor. Also, filter in git-log (like --hide-minor) to hide the minor changes. The git-log could be optimized to show minor commits more discreetly. Thank you. signature.asc Description: OpenPGP digital signature
can't install on OS X
What's the procedure for installing Git under OS X 10.11? I downloaded "git-2.5.3-intel-universal-mavericks.dmg" per instructions. When I tried to install it, I first had trouble because it wasn't from the Mac App Store nor an "identified developer". I ultimately found "System Preferences" > "Security & Privacy" > "Click the lock to make changes" > entered password > AND clicked to "Allow apps downloaded from: Anywhere". Then the install appeared to run and proclaimed, "The installation was successful." However, git is not listed under "Applications", and RStudio says, "Git was not detected on the system path." "README.txt" says I need "sudo mv /usr/bin/git /usr/bin/git-system". I tried that and got, "mv: rename /usr/bin/git to /usr/bin/git-system: Operation not permitted" (after entering my password). [My directory now includes "/usr/local/git", and "/usr/bin" includes git, git-cvsserver, git-receive-pack, git-shell, git-upload-archive, and git-upload-pack.] Suggestions? Thanks, Spencer Graves -- 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 01/43] refs.c: create a public version of verify_refname_available
On 29.09.15 00:01, David Turner wrote: > (Not sure if this is the right thread to report on) In file included from builtin/commit.c:20: ./refs.h:695:16: warning: redefinition of typedef 'ref_transaction_free_fn' is a C11 feature [-Wtypedef-redefinition] typedef void (*ref_transaction_free_fn)(struct ref_transaction *transaction); ^ -- 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 41/68] init: use strbufs to store paths
On 30.09.15 02:23, Jeff King wrote: > On Tue, Sep 29, 2015 at 04:50:39PM -0700, Michael Blume wrote: > >> I see compile errors on my mac: >> This is my attempt, passing the test, but not fully polished. diff --git a/builtin/init-db.c b/builtin/init-db.c index 89f2c05..60b559c 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -276,7 +276,9 @@ static int create_default_files(const char *template_path) path = git_path_buf(, "CoNfIg"); if (!access(path, F_OK)) git_config_set("core.ignorecase", "true"); - probe_utf8_pathname_composition(path); + /* Probe utf-8 normalization withou mangling CoNfIG */ + path = git_path_buf(, "config"); + probe_utf8_pathname_composition(path, strlen(path)); } strbuf_release(); diff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c index b4dd3c7..37172a4 100644 --- a/compat/precompose_utf8.c +++ b/compat/precompose_utf8.c @@ -8,6 +8,7 @@ #include "cache.h" #include "utf8.h" #include "precompose_utf8.h" +#include "strbuf.h" typedef char *iconv_ibp; static const char *repo_encoding = "UTF-8"; @@ -36,28 +37,33 @@ static size_t has_non_ascii(const char *s, size_t maxlen, size_t *strlen_c) } -void probe_utf8_pathname_composition(struct strbuf *path) +void probe_utf8_pathname_composition(char *path, int len) { static const char *auml_nfc = "\xc3\xa4"; static const char *auml_nfd = "\x61\xcc\x88"; - size_t baselen = path->len; + struct strbuf sbuf; int output_fd; if (precomposed_unicode != -1) return; /* We found it defined in the global config, respect it */ - strbuf_addstr(path, auml_nfc); - output_fd = open(path, O_CREAT|O_EXCL|O_RDWR, 0600); + strbuf_init(, len+3); + strbuf_add(, path, len); + strbuf_addstr(, auml_nfc); + output_fd = open(sbuf.buf, O_CREAT|O_EXCL|O_RDWR, 0600); + fprintf(stderr, "%s/%s:%d sbuf.buf=%s\n", + __FILE__, __FUNCTION__, __LINE__, sbuf.buf); if (output_fd >= 0) { close(output_fd); - strbuf_setlen(path, baselen); - strbuf_addstr(path, auml_nfd); + strbuf_setlen(, len); + strbuf_addstr(, auml_nfd); + fprintf(stderr, "%s/%s:%d sbuf.buf=%s\n", + __FILE__, __FUNCTION__, __LINE__, sbuf.buf); precomposed_unicode = access(path, R_OK) ? 0 : 1; git_config_set("core.precomposeunicode", precomposed_unicode ? "true" : "false"); - strbuf_setlen(path, baselen); - strbuf_addstr(path, auml_nfc); + strcpy(path + len, auml_nfc); if (unlink(path)) die_errno(_("failed to unlink '%s'"), path); } - strbuf_setlen(path, baselen); + strbuf_release(); } diff --git a/compat/precompose_utf8.h b/compat/precompose_utf8.h index 7fc7be5..3b73585 100644 --- a/compat/precompose_utf8.h +++ b/compat/precompose_utf8.h @@ -27,7 +27,7 @@ typedef struct { } PREC_DIR; void precompose_argv(int argc, const char **argv); -void probe_utf8_pathname_composition(struct strbuf *path); +void probe_utf8_pathname_composition(char *, int); PREC_DIR *precompose_utf8_opendir(const char *dirname); struct dirent_prec_psx *precompose_utf8_readdir(PREC_DIR *dirp); -- 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