* [BUG] git stash -k show the help message for diff-index
From: Matthieu Moy @ 2011-10-05 15:13 UTC (permalink / raw)
To: git
Everything is in the title. No time to bisect/fix this now, but:
$ git status
# On branch master
nothing to commit (working directory clean)
$ git stash -k
usage: git diff-index [-m] [--cached] [<common diff options>] <tree-ish> [<path>...]
common diff options:
-z output diff-raw with lines terminated with NUL.
-p output patch format.
-u synonym for -p.
--patch-with-raw
output both a patch and the diff-raw format.
--stat show diffstat instead of patch.
--numstat show numeric diffstat instead of patch.
--patch-with-stat
output a patch and prepend its diffstat.
--name-only show only names of changed files.
--name-status show names and status of changed files.
--full-index show full object name on index lines.
--abbrev=<n> abbreviate object names in diff-tree header and diff-raw.
-R swap input file pairs.
-B detect complete rewrites.
-M detect renames.
-C detect copies.
--find-copies-harder
try unchanged files as candidate for copy detection.
-l<n> limit rename attempts up to <n> paths.
-O<file> reorder diffs according to the <file>.
-S<string> find filepair whose only one side contains the string.
--pickaxe-all
show all files diff when -S is used and hit is found.
-a --text treat all files as text.
usage: git diff-index [-m] [--cached] [<common diff options>] <tree-ish> [<path>...]
common diff options:
-z output diff-raw with lines terminated with NUL.
-p output patch format.
-u synonym for -p.
--patch-with-raw
output both a patch and the diff-raw format.
--stat show diffstat instead of patch.
--numstat show numeric diffstat instead of patch.
--patch-with-stat
output a patch and prepend its diffstat.
--name-only show only names of changed files.
--name-status show names and status of changed files.
--full-index show full object name on index lines.
--abbrev=<n> abbreviate object names in diff-tree header and diff-raw.
-R swap input file pairs.
-B detect complete rewrites.
-M detect renames.
-C detect copies.
--find-copies-harder
try unchanged files as candidate for copy detection.
-l<n> limit rename attempts up to <n> paths.
-O<file> reorder diffs according to the <file>.
-S<string> find filepair whose only one side contains the string.
--pickaxe-all
show all files diff when -S is used and hit is found.
-a --text treat all files as text.
Saved working directory and index state WIP on master: 977c790 foo
HEAD is now at 977c790 foo
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply
* git-cherry-pick and git-commit --amend in version 1.7.6.4
From: Nicolas Dichtel @ 2011-10-05 14:52 UTC (permalink / raw)
To: git
Hi,
still with version 1.7.6.4, when I do a cherry-pick, that succeeded, I cannot do
a commit --amend after:
# git cherry-pick 3f78d1f210ff89af77f042ab7f4a8fee39feb1c9
[dev 1a04a23] drivers/net/usb/asix.c: Fix unaligned accesses
1 files changed, 33 insertions(+), 1 deletions(-)
# echo $?
0
# git commit --amend
fatal: You are in the middle of a cherry-pick -- cannot amend.
#
The same operations (with the same patch), with version 1.7.3.4 is ok.
Regards,
Nicolas
^ permalink raw reply
* git-cherry-pick and author field in version 1.7.6.4
From: Nicolas Dichtel @ 2011-10-05 14:51 UTC (permalink / raw)
To: git
Hi all,
in the last stable version (1.7.6.4), when I perform a git-cherry-pick, the
initial author of the patch is erased whith my name (it was not the case in
version 1.7.3.4 and prior). Is this behavior intended ? Is there an option to
keep the initial author of the patch?
Regards,
Nicolas
^ permalink raw reply
* Re: Git attributes ignored for root directory
From: Gioele Barabucci @ 2011-10-05 14:47 UTC (permalink / raw)
To: Michael Haggerty; +Cc: git
In-Reply-To: <4E8C481A.1070808@alum.mit.edu>
On 05/10/2011 14:05, Michael Haggerty wrote:
> On 10/04/2011 08:52 PM, Gioele Barabucci wrote:
>> With the newer v1.7.7 I get this, instead:
>>
>> .: show_in_prompt: unspecified
>>
>> I see in the release notes of 1.7.7-rc1 that `check-attr` has been
>> changed to allow relative paths to be specified. Maybe this error is
>> related to that change.
>
> Indeed, your use case is broken by
>
> f5114a40c0d0276ce6ff215a3dc51eb19da5b420
Wow, debug-by-changelog :)
> In fact the support for gitattributes using patterns involving "." was
> pretty spotty in v1.7.6 too. For example,
[...]
> It's not to hard to fix your particular use case. But for a real fix,
> we would need to decide what is the correct behavior in all of the lines
> above marked "?"; specifically, should "." match every subdirectory
> under a given directory, does it match only the directory containing the
> .gitattributes file, or is this construct illegal?
I do not know what the correct behavior should be, but here is my use case.
I use git to version almost all my $HOME dir. In addition to my usual
files there are also separate project repositories under $HOME. I enjoy
using a git-enabled prompt in those projects' dirs but not in my $HOME dir.
So I have this code somewhere in my `~/.bashrc`:
local show_status="$(git check-attr show_in_prompt -- .)"
local show_pattern='^\.: show_in_prompt: (.*)$'
# add the following line to .gitattributes
#
# /. show_in_prompt=no
local show_in_prompt='yes'
if [[ ${show_status} =~ ${show_pattern} ]]; then
show_in_prompt="${BASH_REMATCH[1]}"
fi
if [ "${show_in_prompt}" == 'no' ]; then
return
fi
As you see in my the line of this code, I exploit the fact that "."
refers to the root git dir, not to the current dir, to simplify the
code. Otherwise I would had to discover what is the path of the current
dir relative to its root git dir, something that I'd like to avoid as
this code runs every time the prompt is shown.
This is just my personal use case. On the other hand, the first time I
looked at check-attr I found it strange that paths were meant as
relative to the root git dir ("." in "/foo" = "/") and not expanded from
the current dir ("." in "/foo" = "/foo").
Bye,
--
Gioele Barabucci <gioele@svario.it>
^ permalink raw reply
* Re: git commit -a reports untracked files after a clone
From: Joerg Rosenkranz @ 2011-10-05 14:26 UTC (permalink / raw)
To: git
In-Reply-To: <20110527181321.GB29119@sigill.intra.peff.net>
> On Fri, May 27, 2011 at 02:00:45PM -0400, Jeff King wrote:
> 1. We load the index, and for each entry, insert it into the index's
> name_hash. In addition, if ignorecase is turned on, we make an
> entry in the name_hash for the directory (e.g., "contrib/"), which
> uses the following code from 5102c61's hash_index_entry_directories:
Sorry for reactivating this old thread.
We are running in this problem too. The behavior is the same in msysgit and on
Linux. Your patch resolves that problem for us.
Is there any chance to drive this patch forward?
Thanks,
Joerg
^ permalink raw reply
* Re: [PATCHv3 1/5] enter_repo: do not modify input
From: Thomas Adam @ 2011-10-05 14:02 UTC (permalink / raw)
To: Phil Hord
Cc: git@vger.kernel.org, Phil Hord, Junio C Hamano, Erik Faye-Lund,
Nguyen Thai Ngoc Duy
In-Reply-To: <4E8C6233.8040906@cisco.com>
On 5 October 2011 14:57, Phil Hord <hordp@cisco.com> wrote:
> From: Erik Faye-Lund <kusmabite@gmail.com>
>
> entr_repo(..., 0) currently modifies the input to strip away
enter_repo???
-- Thomas Adam
^ permalink raw reply
* Re: [PATCHv3 1/5] enter_repo: do not modify input
From: Phil Hord @ 2011-10-05 13:57 UTC (permalink / raw)
To: git@vger.kernel.org, Phil Hord
Cc: Junio C Hamano, Erik Faye-Lund, Nguyen Thai Ngoc Duy
In-Reply-To: <4E8C5D4A.7060900@cisco.com>
From: Erik Faye-Lund <kusmabite@gmail.com>
entr_repo(..., 0) currently modifies the input to strip away
trailing slashes. This means that we some times need to copy the
input to keep the original.
Change it to unconditionally copy it into the used_path buffer so
we can safely use the input without having to copy it. Also store
a working copy in validated_path up-front before we start
resolving anything.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Phil Hord <hordp@cisco.com>
---
Don't know why I keep screwing up this one commit. Here's another try with Word-Wrap in the Really, Really Off position.
diff --git a/cache.h b/cache.h
index 9994a3c..7eeb8cf 100644
--- a/cache.h
+++ b/cache.h
@@ -734,7 +734,7 @@ int safe_create_leading_directories(char *path);
int safe_create_leading_directories_const(const char *path);
int mkdir_in_gitdir(const char *path);
extern char *expand_user_path(const char *path);
-char *enter_repo(char *path, int strict);
+const char *enter_repo(const char *path, int strict);
static inline int is_absolute_path(const char *path)
{
return is_dir_sep(path[0]) || has_dos_drive_prefix(path);
diff --git a/daemon.c b/daemon.c
index 4c8346d..9253192 100644
--- a/daemon.c
+++ b/daemon.c
@@ -108,11 +108,11 @@ static void NORETURN daemon_die(const char *err, va_list params)
exit(1);
}
-static char *path_ok(char *directory)
+static const char *path_ok(char *directory)
{
static char rpath[PATH_MAX];
static char interp_path[PATH_MAX];
- char *path;
+ const char *path;
char *dir;
dir = directory;
diff --git a/path.c b/path.c
index 6f3f5d5..f3d96aa 100644
--- a/path.c
+++ b/path.c
@@ -283,7 +283,7 @@ return_null:
* links. User relative paths are also returned as they are given,
* except DWIM suffixing.
*/
-char *enter_repo(char *path, int strict)
+const char *enter_repo(const char *path, int strict)
{
static char used_path[PATH_MAX];
static char validated_path[PATH_MAX];
@@ -297,14 +297,17 @@ char *enter_repo(char *path, int strict)
};
int len = strlen(path);
int i;
- while ((1 < len) && (path[len-1] == '/')) {
- path[len-1] = 0;
+ while ((1 < len) && (path[len-1] == '/'))
len--;
- }
+
if (PATH_MAX <= len)
return NULL;
- if (path[0] == '~') {
- char *newpath = expand_user_path(path);
+ strncpy(used_path, path, len);
+ used_path[len] = 0;
+ strcpy(validated_path, used_path);
+
+ if (used_path[0] == '~') {
+ char *newpath = expand_user_path(used_path);
if (!newpath || (PATH_MAX - 10 < strlen(newpath))) {
free(newpath);
return NULL;
@@ -316,24 +319,18 @@ char *enter_repo(char *path, int strict)
* anyway.
*/
strcpy(used_path, newpath); free(newpath);
- strcpy(validated_path, path);
- path = used_path;
}
else if (PATH_MAX - 10 < len)
return NULL;
- else {
- path = strcpy(used_path, path);
- strcpy(validated_path, path);
- }
- len = strlen(path);
+ len = strlen(used_path);
for (i = 0; suffix[i]; i++) {
- strcpy(path + len, suffix[i]);
- if (!access(path, F_OK)) {
+ strcpy(used_path + len, suffix[i]);
+ if (!access(used_path, F_OK)) {
strcat(validated_path, suffix[i]);
break;
}
}
- if (!suffix[i] || chdir(path))
+ if (!suffix[i] || chdir(used_path))
return NULL;
path = validated_path;
}
--
1.7.7.505.ga09f6
^ permalink raw reply related
* Re: [PATCH 0/9] i18n: add PO files to po/
From: Peter Krefting @ 2011-10-05 13:44 UTC (permalink / raw)
To: Git Mailing List
Cc: Ævar Arnfjörð Bjarmason, Jonathan Nieder,
Junio C Hamano, Ramkumar Ramachandra, Marcin Cieślak,
Sam Reed, Jan Engelhardt, Jan Krüger,
Nguyễn Thái Ngọc
In-Reply-To: <CACBZZX5uz5cdoWebYOY-Omu0drnQasJB-12DMZyZ_NX17jzhmg@mail.gmail.com>
Ævar Arnfjörð Bjarmason:
> While we could set up some "i18n maintainer" infrastructure why not just
> have people submit patches to the list like we do for every other file in
> git?
As mentioned, that infrastructure already exists in Translation Project -
http://translationproject.org/html/welcome.html
Submit the POT file at "string freeze" before a stable release, and pull the
translated PO files when the release happens. TP handles the rest.
--
\\// Peter - http://www.softwolves.pp.se/
^ permalink raw reply
* [PATCHv3 1/5] enter_repo: do not modify input
From: Phil Hord @ 2011-10-05 13:36 UTC (permalink / raw)
To: git@vger.kernel.org, Phil Hord
Cc: Junio C Hamano, Erik Faye-Lund, Nguyen Thai Ngoc Duy
From: Erik Faye-Lund <kusmabite@gmail.com>
entr_repo(..., 0) currently modifies the input to strip away
trailing slashes. This means that we some times need to copy the
input to keep the original.
Change it to unconditionally copy it into the used_path buffer so
we can safely use the input without having to copy it. Also store
a working copy in validated_path up-front before we start
resolving anything.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Phil Hord <hordp@cisco.com>
diff --git a/cache.h b/cache.h
index 9994a3c..7eeb8cf 100644
--- a/cache.h
+++ b/cache.h
@@ -734,7 +734,7 @@ int safe_create_leading_directories(char *path);
int safe_create_leading_directories_const(const char *path);
int mkdir_in_gitdir(const char *path);
extern char *expand_user_path(const char *path);
-char *enter_repo(char *path, int strict);
+const char *enter_repo(const char *path, int strict);
static inline int is_absolute_path(const char *path)
{
return is_dir_sep(path[0]) || has_dos_drive_prefix(path);
diff --git a/daemon.c b/daemon.c
index 4c8346d..9253192 100644
--- a/daemon.c
+++ b/daemon.c
@@ -108,11 +108,11 @@ static void NORETURN daemon_die(const char *err,
va_list params)
exit(1);
}
-static char *path_ok(char *directory)
+static const char *path_ok(char *directory)
{
static char rpath[PATH_MAX];
static char interp_path[PATH_MAX];
- char *path;
+ const char *path;
char *dir;
dir = directory;
diff --git a/path.c b/path.c
index 6f3f5d5..f3d96aa 100644
--- a/path.c
+++ b/path.c
@@ -283,7 +283,7 @@ return_null:
* links. User relative paths are also returned as they are given,
* except DWIM suffixing.
*/
-char *enter_repo(char *path, int strict)
+const char *enter_repo(const char *path, int strict)
{
static char used_path[PATH_MAX];
static char validated_path[PATH_MAX];
@@ -297,14 +297,17 @@ char *enter_repo(char *path, int strict)
};
int len = strlen(path);
int i;
- while ((1 < len) && (path[len-1] == '/')) {
- path[len-1] = 0;
+ while ((1 < len) && (path[len-1] == '/'))
len--;
- }
+
if (PATH_MAX <= len)
return NULL;
- if (path[0] == '~') {
- char *newpath = expand_user_path(path);
+ strncpy(used_path, path, len);
+ used_path[len] = 0;
+ strcpy(validated_path, used_path);
+
+ if (used_path[0] == '~') {
+ char *newpath = expand_user_path(used_path);
if (!newpath || (PATH_MAX - 10 < strlen(newpath))) {
free(newpath);
return NULL;
@@ -316,24 +319,18 @@ char *enter_repo(char *path, int strict)
* anyway.
*/
strcpy(used_path, newpath); free(newpath);
- strcpy(validated_path, path);
- path = used_path;
}
else if (PATH_MAX - 10 < len)
return NULL;
- else {
- path = strcpy(used_path, path);
- strcpy(validated_path, path);
- }
- len = strlen(path);
+ len = strlen(used_path);
for (i = 0; suffix[i]; i++) {
- strcpy(path + len, suffix[i]);
- if (!access(path, F_OK)) {
+ strcpy(used_path + len, suffix[i]);
+ if (!access(used_path, F_OK)) {
strcat(validated_path, suffix[i]);
break;
}
}
- if (!suffix[i] || chdir(path))
+ if (!suffix[i] || chdir(used_path))
return NULL;
path = validated_path;
}
--
1.7.7.505.ga09f6
^ permalink raw reply related
* [PATCHv3 5/5] Add test showing git-fetch groks gitfiles
From: Phil Hord @ 2011-10-05 13:35 UTC (permalink / raw)
To: git@vger.kernel.org, Phil Hord
Cc: Junio C Hamano, Erik Faye-Lund, Nguyen Thai Ngoc Duy
Add a test for two subtly different cases: 'git fetch path/.git'
and 'git fetch path' to confirm that transport recognizes both
paths as git repositories when using the gitfile mechanism.
Signed-off-by: Phil Hord <hordp@cisco.com>
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index e810314..87ee016 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -206,6 +206,20 @@ test_expect_success 'clone from .git file' '
git clone dst/.git dst2
'
+test_expect_success 'fetch from .git gitfile' '
+ (
+ cd dst2 &&
+ git fetch ../dst/.git
+ )
+'
+
+test_expect_success 'fetch from gitfile parent' '
+ (
+ cd dst2 &&
+ git fetch ../dst
+ )
+'
+
test_expect_success 'clone separate gitdir where target already exists' '
rm -rf dst &&
test_must_fail git clone --separate-git-dir realgitdir src dst
--
1.7.7.505.ga09f6
^ permalink raw reply related
* [PATCHv3 4/5] Teach transport about the gitfile mechanism
From: Phil Hord @ 2011-10-05 13:35 UTC (permalink / raw)
To: git@vger.kernel.org, Phil Hord
Cc: Junio C Hamano, Erik Faye-Lund, Nguyen Thai Ngoc Duy
The transport_get() function assumes that a regular file is a
bundle rather than a local git directory. Check if the file is
actually a gitfile. If so, do not try to process it as a
bundle, but treat it as a local repository instead.
Signed-off-by: Phil Hord <hordp@cisco.com>
diff --git a/transport.c b/transport.c
index cd49a25..2ff2d68 100644
--- a/transport.c
+++ b/transport.c
@@ -915,7 +915,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
ret->fetch = fetch_objs_via_rsync;
ret->push = rsync_transport_push;
ret->smart_options = NULL;
- } else if (is_local(url) && is_file(url)) {
+ } else if (is_local(url) && is_file(url) && !is_gitfile(url)) {
struct bundle_transport_data *data = xcalloc(1, sizeof(*data));
ret->data = data;
ret->get_refs_list = get_refs_from_bundle;
--
1.7.7.505.ga09f6
^ permalink raw reply related
* [PATCHv3 3/5] Add a common is_gitfile function
From: Phil Hord @ 2011-10-05 13:33 UTC (permalink / raw)
To: git@vger.kernel.org, Phil Hord
Cc: Junio C Hamano, Erik Faye-Lund, Nguyen Thai Ngoc Duy
There are at least two locations in the code that check for
gitfiles. Each one is slightly different for pretty good
reasons. Work towards a common API by abstracting the
"is this a gitfile" question into a single function.
Signed-off-by: Phil Hord <hordp@cisco.com>
diff --git a/builtin/clone.c b/builtin/clone.c
index 488f48e..5110399 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -120,13 +120,7 @@ static char *get_repo_path(const char *repo, int *is_bundle)
return xstrdup(absolute_path(path));
} else if (S_ISREG(st.st_mode) && st.st_size > 8) {
/* Is it a "gitfile"? */
- char signature[8];
- int len, fd = open(path, O_RDONLY);
- if (fd < 0)
- continue;
- len = read_in_full(fd, signature, 8);
- close(fd);
- if (len != 8 || strncmp(signature, "gitdir: ", 8))
+ if (!is_gitfile(path))
continue;
path = read_gitfile(path);
if (path) {
diff --git a/cache.h b/cache.h
index 7eeb8cf..61e1b0f 100644
--- a/cache.h
+++ b/cache.h
@@ -441,6 +441,7 @@ extern const char *get_git_work_tree(void);
extern const char *read_gitfile(const char *path);
extern const char *resolve_gitdir(const char *suspect);
extern void set_git_work_tree(const char *tree);
+extern int is_gitfile(const char *path);
#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
diff --git a/setup.c b/setup.c
index 61c22e6..a3d5a41 100644
--- a/setup.c
+++ b/setup.c
@@ -358,7 +358,7 @@ const char *read_gitfile(const char *path)
if (stat(path, &st))
return NULL;
- if (!S_ISREG(st.st_mode))
+ if (!is_gitfile(path))
return NULL;
fd = open(path, O_RDONLY);
if (fd < 0)
@@ -368,9 +368,6 @@ const char *read_gitfile(const char *path)
close(fd);
if (len != st.st_size)
die("Error reading %s", path);
- buf[len] = '\0';
- if (prefixcmp(buf, "gitdir: "))
- die("Invalid gitfile format: %s", path);
while (buf[len - 1] == '\n' || buf[len - 1] == '\r')
len--;
if (len < 9)
@@ -397,6 +394,32 @@ const char *read_gitfile(const char *path)
return path;
}
+/*
+ * See if the referenced file looks like a 'gitfile'.
+ * Does not try to determine if the referenced gitdir is actually valid.
+ */
+int is_gitfile(const char *path)
+{
+ struct stat st;
+ char buf[9];
+ int fd, len;
+ if (stat(path, &st))
+ return 0;
+ if (!S_ISREG(st.st_mode))
+ return 0;
+ if (st.st_size < 10 || st.st_size > PATH_MAX)
+ return 0;
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return 0;
+ len = read_in_full(fd, buf, sizeof(buf));
+ close(fd);
+ if (len != sizeof(buf))
+ return 0;
+ return !prefixcmp(buf, "gitdir: ");
+}
+
static const char *setup_explicit_git_dir(const char *gitdirenv,
char *cwd, int len,
int *nongit_ok)
--
1.7.7.505.ga09f6
^ permalink raw reply related
* [PATCHv3 2/5] Learn to handle gitfiles in enter_repo
From: Phil Hord @ 2011-10-05 13:31 UTC (permalink / raw)
To: git@vger.kernel.org, Phil Hord
Cc: Junio C Hamano, Erik Faye-Lund, Nguyen Thai Ngoc Duy
The enter_repo() function is used to navigate into a .git
directory. It knows how to find standard alternatives (DWIM) but
it doesn't handle gitfiles created by git init --separate-git-dir.
This means that git-fetch and others do not work with repositories
using the separate-git-dir mechanism.
Teach enter_repo() to deal with the gitfile mechanism by resolving
the path to the redirected path and continuing tests on that path
instead of the found file.
Signed-off-by: Phil Hord <hordp@cisco.com>
---
Not sure how to resolve this for the 'strict' case.
The actual path followed may be different than the version spelled
out on the input path because of resolved symlinks and whatnot.
This function normally returns the unmolested "original" path
that was validated. In case of a gitfile, I think that means
we should return the url resolved from the gitfile contents.
But should we?
The returned path is only used in git-daemon where it gets
further checks for path restrictions.
A. If we return the gitfile-resolved path, this may cause these
path restrictions to fail since the path gets canonicalized
when the gitfile is created by git.
B. If we do not return the gitfile-resolved path, this can create
a security-hole by allowing remote users to access files they
would otherwise have been restricted from. In effect it creates
an alternate symlink mechanism of which the administator might
not be aware.
diff --git a/path.c b/path.c
index f3d96aa..46ba326 100644
--- a/path.c
+++ b/path.c
@@ -295,6 +295,7 @@ const char *enter_repo(const char *path, int strict)
static const char *suffix[] = {
".git/.git", "/.git", ".git", "", NULL,
};
+ const char *gitfile;
int len = strlen(path);
int i;
while ((1 < len) && (path[len-1] == '/'))
@@ -330,7 +331,12 @@ const char *enter_repo(const char *path, int strict)
break;
}
}
- if (!suffix[i] || chdir(used_path))
+ if (!suffix[i])
+ return NULL;
+ gitfile = read_gitfile(used_path) ;
+ if (gitfile)
+ strcpy(used_path, gitfile);
+ if (chdir(used_path))
return NULL;
path = validated_path;
}
--
1.7.7.505.ga09f6
^ permalink raw reply related
* Re: [RFC/PATCH] Add multiple workdir support to branch/checkout
From: Jay Soffian @ 2011-10-05 13:11 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy; +Cc: git
In-Reply-To: <CACsJy8AqYq+YF+rvUp=BBeFUAtUz783iF2jbUp3fO58yLp9ptQ@mail.gmail.com>
On Wed, Oct 5, 2011 at 12:02 AM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> Could you please consider a more generic approach? What I have in mind
> is a mechanism to "lock" a branch, so that only commands that have the
> key can update it.
>
> So instead of branch.<name>.checkout, I would have something like
> branch.<name>.locked = <key>, where <key> is just a string. Only
> commands that provide the matching <key> are allowed to update the
> branch. In checkout case, <key> could be "checkout: worktree".
In this case, each workdir needs its own key, so I'd have to record
the key somewhere, unless you meant using a key of "checkout:
</path/to/workdir>".
> This approach addresses more cases than just multiple workdir. We
> could relax restrictions on pushing to a non-bare repository: we only
> disallow pushing to locked branches.
Isn't that another case where you only care if the branch is checked
out and where? So using "branch.<name>.checkout = </path/to/workdir>"
should be fine there too.
> We can also use this to prevent
> users from checking out another branch (by locking HEAD) while in the
> middle of interactive rebase/bisect/...
I dunno, that seems like a really different use case.
j.
^ permalink raw reply
* Re: Git attributes ignored for root directory
From: Michael Haggerty @ 2011-10-05 12:05 UTC (permalink / raw)
To: Gioele Barabucci; +Cc: git
In-Reply-To: <4E8B55FB.1050203@svario.it>
On 10/04/2011 08:52 PM, Gioele Barabucci wrote:
> I just updated to git v1.7.7 using the Ubuntu Lucid PPA and I found that
> `git check-attr` is broken now.
>
> I have this attribute in my `$HOME/.gitattributes` file:
>
> /. show_in_prompt=no
>
> Now, if I go to `$HOME` and run
>
> git check-attr show_in_prompt -- .
>
> With git v1.7.6 this is the answer I got:
>
> .: show_in_prompt: no
>
> With the newer v1.7.7 I get this, instead:
>
> .: show_in_prompt: unspecified
>
> Also, if I use the `--all` option, `check-attr` does not show any
> attribute at all.
>
> I see in the release notes of 1.7.7-rc1 that `check-attr` has been
> changed to allow relative paths to be specified. Maybe this error is
> related to that change.
Indeed, your use case is broken by
f5114a40c0d0276ce6ff215a3dc51eb19da5b420
In fact the support for gitattributes using patterns involving "." was
pretty spotty in v1.7.6 too. For example,
-------------------------------------------
echo ". foo" >./.gitattributes
git check-attr foo -- . ./ ./. x x/ ./x x/.
.: foo: set
./: foo: unspecified WRONG
./.: foo: set
x: foo: unspecified WRONG?
x/: foo: unspecified WRONG?
./x: foo: unspecified WRONG?
x/.: foo: set RIGHT?
-------------------------------------------
echo "/. foo" >./.gitattributes
git check-attr foo -- . ./ ./. x x/ ./x x/.
.: foo: set
./: foo: unspecified WRONG
./.: foo: set
x: foo: unspecified
x/: foo: unspecified
./x: foo: unspecified
x/.: foo: unspecified
-------------------------------------------
echo ". foo" >x/.gitattributes
git check-attr foo -- . ./ ./. x x/ ./x x/.
.: foo: unspecified
./: foo: unspecified
./.: foo: unspecified
x: foo: unspecified WRONG?
x/: foo: unspecified WRONG?
./x: foo: unspecified WRONG?
x/.: foo: set RIGHT?
-------------------------------------------
echo "/. foo" >x/.gitattributes
git check-attr foo -- . ./ ./. x x/ ./x x/.
.: foo: unspecified
./: foo: unspecified
./.: foo: unspecified
x: foo: unspecified WRONG
x/: foo: unspecified WRONG
./x: foo: unspecified WRONG
x/.: foo: set
-------------------------------------------
I conclude that this functionality was never really defined correctly,
and you were pretty lucky that your case worked at all :-)
It's not to hard to fix your particular use case. But for a real fix,
we would need to decide what is the correct behavior in all of the lines
above marked "?"; specifically, should "." match every subdirectory
under a given directory, does it match only the directory containing the
.gitattributes file, or is this construct illegal?
Michael
--
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
^ permalink raw reply
* [PATCH] git-svn: On MSYS, escape and quote SVN_SSH also if set by the user
From: Sebastian Schuberth @ 2011-10-05 9:14 UTC (permalink / raw)
To: git; +Cc: msysgit
While GIT_SSH does not require any escaping / quoting (e.g. for paths
containing spaces), SVN_SSH requires it due to its use in a Perl script.
Previously, SVN_SSH has only been escaped and quoted automatically if it
was unset and thus derived from GIT_SSH. For user convenience, do the
escaping and quoting also for a SVN_SSH set by the user. This way, the
user is able to use the same unescaped and unquoted syntax for GIT_SSH
and SVN_SSH.
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
---
git-svn.perl | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 89f83fd..c3b4b58 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -22,14 +22,13 @@ $Git::SVN::default_ref_id = $ENV{GIT_SVN_ID} || 'git-svn';
$Git::SVN::Ra::_log_window_size = 100;
$Git::SVN::_minimize_url = 'unset';
-if (! exists $ENV{SVN_SSH}) {
- if (exists $ENV{GIT_SSH}) {
- $ENV{SVN_SSH} = $ENV{GIT_SSH};
- if ($^O eq 'msys') {
- $ENV{SVN_SSH} =~ s/\\/\\\\/g;
- $ENV{SVN_SSH} =~ s/(.*)/"$1"/;
- }
- }
+if (! exists $ENV{SVN_SSH} && exists $ENV{GIT_SSH}) {
+ $ENV{SVN_SSH} = $ENV{GIT_SSH};
+}
+
+if (exists $ENV{SVN_SSH} && $^O eq 'msys') {
+ $ENV{SVN_SSH} =~ s/\\/\\\\/g;
+ $ENV{SVN_SSH} =~ s/(.*)/"$1"/;
}
$Git::SVN::Log::TZ = $ENV{TZ};
--
1.7.6.GIT
^ permalink raw reply related
* Re: pack-object poor performance (with large number of objects?)
From: Piotr Krukowiecki @ 2011-10-05 8:48 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, Shawn Pearce, Git Mailing List, Ingo Molnar
In-Reply-To: <20111004180829.GB31671@sigill.intra.peff.net>
On Tue, Oct 4, 2011 at 8:08 PM, Jeff King <peff@peff.net> wrote:
> On Tue, Oct 04, 2011 at 03:21:24PM +0200, Piotr Krukowiecki wrote:
>
>> I have 4GB ram + 4GB swap. Is it possible the RAM is the problem if I
>> always have free RAM left and my swap is almost not used?
>> For example at the moment repack finished counting objects ("Counting
>> objects: 1742200, done."):
>>
>> $ free -m
>> total used free shared buffers cached
>> Mem: 3960 3814 146 0 441 215
>> -/+ buffers/cache: 3157 803
>> Swap: 6143 694 5449
>
[...]
> I have no idea if this will actually go faster for you. But it might be
> worth trying, instead of just redoing the svn import with auto-gc turned
> on.
I've left it to run over night and it finished (took almost 12 hours),
so hopefully I'm not going to run into this problem anymore.
$ time git repack -a -d -f
Counting objects: 1742200, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1291909/1291909), done.
Writing objects: 100% (1742200/1742200), done.
Total 1742200 (delta 1094325), reused 39192 (delta 0)
Removing duplicate objects: 100% (256/256), done.
real 704m3.477s
user 65m35.960s
sys 9m50.880s
$ du -sh .git/objects/pack
3.9G .git/objects/pack
$ git count-objects -v
count: 0
size: 0
in-pack: 1742200
packs: 1
size-pack: 4078245
prune-packable: 0
garbage: 0
--
Piotr Krukowiecki
^ permalink raw reply
* Re: [PATCH WIP 0/3] git log --exclude
From: Nguyen Thai Ngoc Duy @ 2011-10-05 8:28 UTC (permalink / raw)
To: Matthieu Moy; +Cc: git, Jonathan Nieder
In-Reply-To: <vpqd3ebn9nc.fsf@bauges.imag.fr>
2011/10/5 Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>:
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>
>> This series adds --exclude that uses .gitignore mechanism remove
>> commits whose changes that are _entirely_ excluded.
>
> I'd see this --exclude as the opposite of specifying files, i.e. in a
> repository containing directories A, B and C,
>
> git log --exclude=B
>
> would be the same as
>
> git log A C
I think I emphasized it too much. "git log --exclude=B/ A B C" should
be equivalent to "git log A C". If changes touch A or C, then no
matter they touch B, the commit will always be in. If changes only
touch B, neither A nor B, then the commit is removed, exactly the same
case with "git log A C".
>> Because it uses .gitignore mechanism, beware that these patterns do
>> not behave exactly like pathspecs
if you specify --exclude=B, then A/.../B, C/.../B are all removed. A
subtle difference between pathspec and .gitignore.
> and because "git log --stat A C" (or --patch) will show the diff only
> for A and C for commits touching all directories.
I'll take care of --patch and friends later. They both (--patch and
commit pruning) use the same diff mechanism, if we get it right for
for commit pruning, --patch will come nicely.
--
Duy
^ permalink raw reply
* [PATCH] Report errors related to .git access during repository discovery
From: Nguyễn Thái Ngọc Duy @ 2011-10-05 8:17 UTC (permalink / raw)
To: Johannes Sixt
Cc: git, Federico Lucifredi, Nguyễn Thái Ngọc Duy
In-Reply-To: <4E8BF519.8090509@viscovery.net>
If $GIT_DIR is not given, we go up step by step and look for potential
repository directory, may see .git directory but for some reasons we
decide to skip and move on.
It's probably better to report along the line, so users can stop
wondering "hey, but I have .git directory _there_".
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
On Wed, Oct 5, 2011 at 5:11 PM, Johannes Sixt <j.sixt@viscovery.net> wrote:
> Am 10/4/2011 23:24, schrieb Federico Lucifredi:
>> Hello Git list,
>> Found a minor bug in git today - the error message reported is not
>> correct when trying to access a repo that is not accessible
>> permission-wise:
>>
>>> federico@skyplex:/etc$ git log
>>> fatal: Not a git repository (or any of the parent directories): .git
>>
>> with correct access permissions, everything works as expected.
>
> And the correct error message is...?
That's a correct message. But it'd be even better if we help diagnose
why. Even when you have proper access to .git dir, git can still
refuse to accept the directory as a repository, because "HEAD" is
invalid for example.
I think a patch like this is an improvement. There may be many
situations git refuses a directory but I don't cover here. Well, we
may when users report them
setup.c | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/setup.c b/setup.c
index 27c1d47..b6028e5 100644
--- a/setup.c
+++ b/setup.c
@@ -269,6 +269,19 @@ const char *pathspec_prefix(const char *prefix, const char **pathspec)
}
/*
+ * This function is used during .git detection phase. If .git does not
+ * exist, it's OK not to report because that happens a lot if you stay
+ * inside a subdirectory and git checks every level back to topdir.
+ */
+static int access_and_warn(const char *path, int perm)
+{
+ int ret = access(path, perm);
+ if (ret && errno != ENOENT)
+ error("%s: %s", absolute_path(path), strerror(errno));
+ return ret;
+}
+
+/*
* Test if it looks like we're at a git directory.
* We want to see:
*
@@ -288,22 +301,24 @@ static int is_git_directory(const char *suspect)
die("Too long path: %.*s", 60, suspect);
strcpy(path, suspect);
if (getenv(DB_ENVIRONMENT)) {
- if (access(getenv(DB_ENVIRONMENT), X_OK))
+ if (access_and_warn(getenv(DB_ENVIRONMENT), X_OK))
return 0;
}
else {
strcpy(path + len, "/objects");
- if (access(path, X_OK))
+ if (access_and_warn(path, X_OK))
return 0;
}
strcpy(path + len, "/refs");
- if (access(path, X_OK))
+ if (access_and_warn(path, X_OK))
return 0;
strcpy(path + len, "/HEAD");
- if (validate_headref(path))
+ if (validate_headref(path)) {
+ error("invalid HEAD at %s", absolute_path(path));
return 0;
+ }
return 1;
}
--
1.7.3.1.256.g2539c.dirty
^ permalink raw reply related
* Re: [PATCH WIP 0/3] git log --exclude
From: Matthieu Moy @ 2011-10-05 8:08 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git, Jonathan Nieder
In-Reply-To: <1317799088-26626-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> This series adds --exclude that uses .gitignore mechanism remove
> commits whose changes that are _entirely_ excluded.
I'd see this --exclude as the opposite of specifying files, i.e. in a
repository containing directories A, B and C,
git log --exclude=B
would be the same as
git log A C
If I understand correctly, it's not the case with your implementation
because
> Because it uses .gitignore mechanism, beware that these patterns do
> not behave exactly like pathspecs
and because "git log --stat A C" (or --patch) will show the diff only
for A and C for commits touching all directories.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply
* Re: Git Bug report
From: Fredrik Gustafsson @ 2011-10-05 7:22 UTC (permalink / raw)
To: Federico Lucifredi; +Cc: git
In-Reply-To: <1317763443.17036.15.camel@skyplex>
On Tue, Oct 04, 2011 at 05:24:03PM -0400, Federico Lucifredi wrote:
> Found a minor bug in git today - the error message reported is not
> correct when trying to access a repo that is not accessible
> permission-wise:
>
> > federico@skyplex:/etc$ git log
> > fatal: Not a git repository (or any of the parent directories): .git
>
> with correct access permissions, everything works as expected.
So if:
.git/ is a directory with not enought permissions.
../.git/ is a directory with enought permissions.
git would today use ../.git. You suggest that git instead would die
because a .git/ exists? (I'm not saying this is wrong or right).
--
Med vänliga hälsningar
Fredrik Gustafsson
E-post: iveqy@iveqy.com
Tel. nr.: 0733 60 82 74
^ permalink raw reply
* [PATCH WIP 3/3] log: add --exclude option
From: Nguyễn Thái Ngọc Duy @ 2011-10-05 7:18 UTC (permalink / raw)
To: git; +Cc: Jonathan Nieder, Nguyễn Thái Ngọc Duy
In-Reply-To: <1317799088-26626-1-git-send-email-pclouds@gmail.com>
This only helps filtering out commits whose changes are _entirely_ filtered out.
This does not affect patch generate (--patch, --stat and so on)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
revision.c | 7 +++++--
revision.h | 2 ++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/revision.c b/revision.c
index c46cfaa..8472553 100644
--- a/revision.c
+++ b/revision.c
@@ -334,8 +334,8 @@ static int rev_compare_tree(struct rev_info *revs, struct commit *parent, struct
tree_difference = REV_TREE_SAME;
DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
- if (diff_tree_sha1(t1->object.sha1, t2->object.sha1, "",
- &revs->pruning) < 0)
+ if (diff_tree_sha1_with_exclude(t1->object.sha1, t2->object.sha1, "",
+ &revs->pruning, &revs->el, 0, 0) < 0)
return REV_TREE_DIFFERENT;
return tree_difference;
}
@@ -1454,6 +1454,9 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
return argcount;
} else if (!strcmp(arg, "--log-size")) {
revs->show_log_size = 1;
+ } else if (!prefixcmp(arg, "--exclude=")) {
+ add_exclude(arg + 10, "", 0, &revs->el);
+ revs->prune = 1;
}
/*
* Grepping the commit log
diff --git a/revision.h b/revision.h
index 3d64ada..3709959 100644
--- a/revision.h
+++ b/revision.h
@@ -4,6 +4,7 @@
#include "parse-options.h"
#include "grep.h"
#include "notes.h"
+#include "dir.h"
#define SEEN (1u<<0)
#define UNINTERESTING (1u<<1)
@@ -133,6 +134,7 @@ struct rev_info {
/* diff info for patches and for paths limiting */
struct diff_options diffopt;
struct diff_options pruning;
+ struct exclude_list el;
struct reflog_walk_info *reflog_info;
struct decoration children;
--
1.7.3.1.256.g2539c.dirty
^ permalink raw reply related
* [PATCH WIP 2/3] tree-diff: teach it to understand exclude patterns
From: Nguyễn Thái Ngọc Duy @ 2011-10-05 7:18 UTC (permalink / raw)
To: git; +Cc: Jonathan Nieder, Nguyễn Thái Ngọc Duy
In-Reply-To: <1317799088-26626-1-git-send-email-pclouds@gmail.com>
We introduce a new set of API, diff_tree_*_with_exclude, that also
exclude entries based on .gitignore patterns.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
diff.h | 11 +++++++++++
tree-diff.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 65 insertions(+), 4 deletions(-)
diff --git a/diff.h b/diff.h
index 8c66b59..51c8a5f 100644
--- a/diff.h
+++ b/diff.h
@@ -12,6 +12,7 @@ struct diff_queue_struct;
struct strbuf;
struct diff_filespec;
struct userdiff_driver;
+struct exclude_list;
typedef void (*change_fn_t)(struct diff_options *options,
unsigned old_mode, unsigned new_mode,
@@ -170,8 +171,18 @@ extern void diff_tree_setup_paths(const char **paths, struct diff_options *);
extern void diff_tree_release_paths(struct diff_options *);
extern int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
const char *base, struct diff_options *opt);
+extern int diff_tree_with_exclude(struct tree_desc *t1, struct tree_desc *t2,
+ const char *base, struct diff_options *opt,
+ struct exclude_list *el,
+ int def_excl1, int def_excl2);
extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
const char *base, struct diff_options *opt);
+extern int diff_tree_sha1_with_exclude(const unsigned char *old,
+ const unsigned char *new,
+ const char *base,
+ struct diff_options *opt,
+ struct exclude_list *el,
+ int def_excl1, int def_excl2);
extern int diff_root_tree_sha1(const unsigned char *new, const char *base,
struct diff_options *opt);
diff --git a/tree-diff.c b/tree-diff.c
index b3cc2e4..9938ccf 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -5,12 +5,14 @@
#include "diff.h"
#include "diffcore.h"
#include "tree.h"
+#include "dir.h"
static void show_entry(struct diff_options *opt, const char *prefix,
struct tree_desc *desc, struct strbuf *base);
static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2,
- struct strbuf *base, struct diff_options *opt)
+ struct strbuf *base, struct diff_options *opt,
+ struct exclude_list *el, int def_excl1, int def_excl2)
{
unsigned mode1, mode2;
const char *path1, *path2;
@@ -52,7 +54,8 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2,
sha1, sha2, base->buf, 0, 0);
}
strbuf_addch(base, '/');
- diff_tree_sha1(sha1, sha2, base->buf, opt);
+ diff_tree_sha1_with_exclude(sha1, sha2, base->buf, opt,
+ el, def_excl1, def_excl2);
} else {
opt->change(opt, mode1, mode2, sha1, sha2, base->buf, 0, 0);
}
@@ -113,6 +116,31 @@ static void show_entry(struct diff_options *opt, const char *prefix,
strbuf_setlen(base, old_baselen);
}
+static int skip_excludes(struct tree_desc *t, struct strbuf *base,
+ struct exclude_list *el, int defval)
+{
+ for (; t->size; update_tree_entry(t)) {
+ /*
+ * excluded_from_list only cares whether dtype is
+ * DT_DIR or something else (except DT_UNKNOWN). Any
+ * other value would do
+ */
+ int dtype = S_ISDIR(t->entry.mode) ? DT_DIR : DT_REG;
+ int ret = excluded_from_list(base->buf, base->len, t->entry.path,
+ &dtype, el);
+
+ /* If undecided, use matching result of parent dir in defval */
+ if (ret < 0)
+ ret = defval;
+
+ if (ret == 1 && dtype == DT_REG)
+ ;
+ else
+ return ret;
+ }
+ return defval;
+}
+
static void skip_uninteresting(struct tree_desc *t, struct strbuf *base,
struct diff_options *opt, int *match)
{
@@ -130,9 +158,17 @@ static void skip_uninteresting(struct tree_desc *t, struct strbuf *base,
int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
const char *base_str, struct diff_options *opt)
{
+ return diff_tree_with_exclude(t1, t2, base_str, opt, NULL, 0, 0);
+}
+
+int diff_tree_with_exclude(struct tree_desc *t1, struct tree_desc *t2,
+ const char *base_str, struct diff_options *opt,
+ struct exclude_list *el, int def_excl1, int def_excl2)
+{
struct strbuf base;
int baselen = strlen(base_str);
int t1_match = 0, t2_match = 0;
+ int excl1 = 0, excl2 = 0;
/* Enable recursion indefinitely */
opt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE);
@@ -148,6 +184,10 @@ int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
skip_uninteresting(t1, &base, opt, &t1_match);
skip_uninteresting(t2, &base, opt, &t2_match);
}
+ if (el && el->nr) {
+ excl1 = skip_excludes(t1, &base, el, def_excl1);
+ excl2 = skip_excludes(t2, &base, el, def_excl2);
+ }
if (!t1->size) {
if (!t2->size)
break;
@@ -160,7 +200,7 @@ int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
update_tree_entry(t1);
continue;
}
- switch (compare_tree_entry(t1, t2, &base, opt)) {
+ switch (compare_tree_entry(t1, t2, &base, opt, el, excl1, excl2)) {
case -1:
update_tree_entry(t1);
continue;
@@ -267,6 +307,16 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const char *base, struct diff_options *opt)
{
+ return diff_tree_sha1_with_exclude(old, new, base, opt, NULL, 0, 0);
+}
+
+int diff_tree_sha1_with_exclude(const unsigned char *old,
+ const unsigned char *new,
+ const char *base,
+ struct diff_options *opt,
+ struct exclude_list *el,
+ int def_excl1, int def_excl2)
+{
void *tree1, *tree2;
struct tree_desc t1, t2;
unsigned long size1, size2;
@@ -280,7 +330,7 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha
die("unable to read destination tree (%s)", sha1_to_hex(new));
init_tree_desc(&t1, tree1, size1);
init_tree_desc(&t2, tree2, size2);
- retval = diff_tree(&t1, &t2, base, opt);
+ retval = diff_tree_with_exclude(&t1, &t2, base, opt, el, def_excl1, def_excl2);
if (!*base && DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename()) {
init_tree_desc(&t1, tree1, size1);
init_tree_desc(&t2, tree2, size2);
--
1.7.3.1.256.g2539c.dirty
^ permalink raw reply related
* [PATCH WIP 1/3] diff-no-index: rename read_directory to avoid conflict from dir.h
From: Nguyễn Thái Ngọc Duy @ 2011-10-05 7:18 UTC (permalink / raw)
To: git; +Cc: Jonathan Nieder, Nguyễn Thái Ngọc Duy
In-Reply-To: <1317799088-26626-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
diff-no-index.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/diff-no-index.c b/diff-no-index.c
index 3a36144..927abb7 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -16,7 +16,7 @@
#include "builtin.h"
#include "string-list.h"
-static int read_directory(const char *path, struct string_list *list)
+static int read_entire_directory(const char *path, struct string_list *list)
{
DIR *dir;
struct dirent *e;
@@ -68,9 +68,9 @@ static int queue_diff(struct diff_options *o,
struct string_list p2 = STRING_LIST_INIT_DUP;
int len1 = 0, len2 = 0, i1, i2, ret = 0;
- if (name1 && read_directory(name1, &p1))
+ if (name1 && read_entire_directory(name1, &p1))
return -1;
- if (name2 && read_directory(name2, &p2)) {
+ if (name2 && read_entire_directory(name2, &p2)) {
string_list_clear(&p1, 0);
return -1;
}
--
1.7.3.1.256.g2539c.dirty
^ permalink raw reply related
* [PATCH WIP 0/3] git log --exclude
From: Nguyễn Thái Ngọc Duy @ 2011-10-05 7:18 UTC (permalink / raw)
To: git; +Cc: Jonathan Nieder, Nguyễn Thái Ngọc Duy
This series adds --exclude that uses .gitignore mechanism remove
commits whose changes that are _entirely_ excluded. The main patch is
2/3 where it teaches diff_tree_* about struct exclude_list.
Because it uses .gitignore mechanism, beware that these patterns do
not behave exactly like pathspecs (patterns without slashes match
every directory, for example)
I tried these commands
time git log --stat >/dev/null
time git log --stat --exclude=Documentation >/dev/null
The former took 37 secs, the latter 40 secs. Not bad, but there is
definitely room for improvement. skip_excludes() should be able to
point out whether an entire directory is excluded and skip the whole
directory (as opposed to descending in and checking files one by one
now, in fear of negative patterns). These kinds of optimizations
benefit sparse checkout too.
I think I made a mistake somewhere because the above command seems to
remove more commits than it should... Regardless,
"git log --exclude=po" on gnome-shell looks sooo clean.
Nguyễn Thái Ngọc Duy (3):
diff-no-index: rename read_directory to avoid conflict from dir.h
tree-diff: teach it to understand exclude patterns
log: add --exclude option
diff-no-index.c | 6 ++--
diff.h | 11 ++++++++++
revision.c | 7 ++++-
revision.h | 2 +
tree-diff.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++---
5 files changed, 75 insertions(+), 9 deletions(-)
--
1.7.3.1.256.g2539c.dirty
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox