Re: [PATCH] commit: ignore assume-unchanged files in commmit file mode

2014-12-08 Thread Sérgio Basto
On Sex, 2014-12-05 at 17:56 +0700, Nguyễn Thái Ngọc Duy wrote: 
 In the same spirit of 7fce6e3 (commit: correctly respect skip-worktree
 bit - 2009-12-14), if a file is marked unchanged, skip it.
 
 Noticed-by: Sérgio Basto ser...@serjux.com
 Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
 ---
  builtin/commit.c |  2 +-
  t/t2106-update-index-assume-unchanged.sh | 10 ++
  2 files changed, 11 insertions(+), 1 deletion(-)
 
 diff --git a/builtin/commit.c b/builtin/commit.c
 index e108c53..ee3de12 100644
 --- a/builtin/commit.c
 +++ b/builtin/commit.c
 @@ -252,7 +252,7 @@ static int list_paths(struct string_list *list, const 
 char *with_tree,
   if (!ce_path_match(ce, pattern, m))
   continue;
   item = string_list_insert(list, ce-name);
 - if (ce_skip_worktree(ce))
 + if (ce-ce_flags  (CE_VALID | CE_SKIP_WORKTREE))
   item-util = item; /* better a valid pointer than a 
 fake one */
   }
  
 diff --git a/t/t2106-update-index-assume-unchanged.sh 
 b/t/t2106-update-index-assume-unchanged.sh
 index 99d858c..dc332f5 100755
 --- a/t/t2106-update-index-assume-unchanged.sh
 +++ b/t/t2106-update-index-assume-unchanged.sh
 @@ -21,4 +21,14 @@ test_expect_success 'do not switch branches with dirty 
 file' \
git update-index --assume-unchanged file 
test_must_fail git checkout master'
  
 +test_expect_success 'commit paths ignore assume-unchanged files' '
 + : anotherfile 
 + git add anotherfile 
 + echo dirty anotherfile 
 + git commit -m one -- file anotherfile 
 + git diff --name-only HEAD^ HEAD actual 
 + echo anotherfile expected 
 + test_cmp expected actual
 +'
 +
  test_done


works great many thanks, 

-- 
Sérgio M. B.

--
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: fast-import should not care about core.ignorecase

2014-12-08 Thread Joshua Jensen

Jonathan Nieder wrote on 12/8/2014 6:31 PM:

Joshua Jensen wrote:

I think it has been discussed before, but maybe Git needs a
core.casefold in addition to core.ignorecase.)

Would it work for --casefold to be a commandline flag to fast-import,
instead of a global option affecting multiple Git commands?
Given that core.ignorecase=true means to fold filename case in quite a 
number of places within Git right now, I would expect the same behavior 
within a repository where fast-import is being run against 
core.ignorecase=true.


So, I don't know what core.ignorecase should mean, but I'm pretty sure I 
know what core.foldcase should mean.


Would --casefold work?  Sure, but it would be a special case against the 
existing core.ignorecase behavior that I don't think makes much sense.


Josh
--
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] doc: make clear --assume-unchanged's user contract

2014-12-08 Thread Sérgio Basto
On Sáb, 2014-12-06 at 15:04 +, Philip Oakley wrote: 
 Many users misunderstand the --assume-unchanged contract, believing
 it means Git won't look at the flagged file.
 
 Be explicit that the --assume-unchanged contract is by the user that
 they will NOT change the file so that Git does not need to look (and
 expend, for example, lstat(2) cycles)
 
 Mentioning Git stops checking does not help the reader, as it is
 only one possible consequence of what that assumption allows Git to
 do, but
 
(1) there are things other than stop checking that Git can do
based on that assumption; and
(2) Git is not obliged to stop checking; it merely is allowed to.
 
 Also, this is a single flag bit, correct the plural to singular, and
 the verb, accordingly.
 
 Drop the stale and incorrect information about poor-man's ignore,
 which is not what this flag bit is about at all.
 
 Signed-off-by: Philip Oakley philipoak...@iee.org
 ---
  Documentation/git-update-index.txt | 18 --
  1 file changed, 8 insertions(+), 10 deletions(-)
 
 diff --git a/Documentation/git-update-index.txt 
 b/Documentation/git-update-index.txt
 index e0a8702..da1ccbc 100644
 --- a/Documentation/git-update-index.txt
 +++ b/Documentation/git-update-index.txt
 @@ -78,20 +78,18 @@ OPTIONS
  Set the execute permissions on the updated files.
  
  --[no-]assume-unchanged::
 - When these flags are specified, the object names recorded
 - for the paths are not updated.  Instead, these options
 - set and unset the assume unchanged bit for the
 - paths.  When the assume unchanged bit is on, Git stops
 - checking the working tree files for possible
 - modifications, so you need to manually unset the bit to
 - tell Git when you change the working tree file. This is
 + When this flag is specified, the object names recorded
 + for the paths are not updated.  Instead, this option
 + sets/unsets the assume unchanged bit for the
 + paths.  When the assume unchanged bit is on, the user
 + promises not to change the file and allows Git to assume
 + that the working tree file matches what is recorded in
 + the index.  If you want to change the working tree file,
 + you need to unset the bit to tell Git.  This is
   sometimes helpful when working with a big project on a
   filesystem that has very slow lstat(2) system call
   (e.g. cifs).
  +
 -This option can be also used as a coarse file-level mechanism
 -to ignore uncommitted changes in tracked files (akin to what
 -`.gitignore` does for untracked files).
  Git will fail (gracefully) in case it needs to modify this file
  in the index e.g. when merging in a commit;
  thus, in case the assumed-untracked file is changed upstream,

I don't understand why you insist that we have a contract, 
when : 
git diff ., git diff -a and git commit -a have a different
behavior of git commit . , this is not about any contract this is
about coherency and be user friendly . 

At least if you want keep things like that, wrote in doc, clearly, that
assume-unchanged flag *is not*, to git ignoring changes in tracked files
and currently not ignore files for git commit path and may not work in
other cases . 

Also don't understand why --assumed-untracked shouldn't deal with
changed files instead fallback in the user promises not to change the
file and sometimes works others not. 

Also if this is the contract when a file is different from commit,
should warning the user that is not in contract (modify files that are
assumed-untracked ) 


Thanks, 
-- 
Sérgio M. B.

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 0/3] Multiple worktrees vs. submodules fixes

2014-12-08 Thread Max Kirillov
After discussions I came to basically same as v1.

* Resubmitting the 2 patches which have not been taken to worktrees reroll -
  they fix visible issue. Mostly unchanged except small cleanup in test.
* Added GIT_COMMON_DIR to local_repo_env. While it is obviously a right
  thing, I wasn't able to observe any change in behavior.

Max Kirillov (3):
  submodule refactor: use git_path_submodule() in add_submodule_odb()
  path: implement common_dir handling in git_path_submodule()
  Add GIT_COMMON_DIR to local_repo_env

 cache.h  |  1 +
 environment.c|  1 +
 path.c   | 24 
 setup.c  | 17 -
 submodule.c  | 28 ++--
 t/t7410-submodule-checkout-to.sh | 10 ++
 6 files changed, 54 insertions(+), 27 deletions(-)

-- 
2.2.0.50.gb2b6831

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/3] path: implement common_dir handling in git_path_submodule()

2014-12-08 Thread Max Kirillov
This allows making submodules a linked workdirs.

Same as for .git, but ignores the GIT_COMMON_DIR environment variable,
because it would mean common directory for the parent repository and
does not make sense for submodule.

Also add test for functionality which uses this call.

Signed-off-by: Max Kirillov m...@max630.net
---
 cache.h  |  1 +
 path.c   | 24 
 setup.c  | 17 -
 t/t7410-submodule-checkout-to.sh | 10 ++
 4 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/cache.h b/cache.h
index 3f60a11..e8f465a 100644
--- a/cache.h
+++ b/cache.h
@@ -437,6 +437,7 @@ extern char *get_object_directory(void);
 extern char *get_index_file(void);
 extern char *get_graft_file(void);
 extern int set_git_dir(const char *path);
+extern int get_common_dir_noenv(struct strbuf *sb, const char *gitdir);
 extern int get_common_dir(struct strbuf *sb, const char *gitdir);
 extern const char *get_git_namespace(void);
 extern const char *strip_namespace(const char *namespaced_ref);
diff --git a/path.c b/path.c
index a5c51a3..78f718f 100644
--- a/path.c
+++ b/path.c
@@ -98,7 +98,7 @@ static const char *common_list[] = {
NULL
 };
 
-static void update_common_dir(struct strbuf *buf, int git_dir_len)
+static void update_common_dir(struct strbuf *buf, int git_dir_len, const char* 
common_dir)
 {
char *base = buf-buf + git_dir_len;
const char **p;
@@ -115,12 +115,17 @@ static void update_common_dir(struct strbuf *buf, int 
git_dir_len)
path++;
is_dir = 1;
}
+
+   if (!common_dir) {
+   common_dir = get_git_common_dir();
+   }
+
if (is_dir  dir_prefix(base, path)) {
-   replace_dir(buf, git_dir_len, get_git_common_dir());
+   replace_dir(buf, git_dir_len, common_dir);
return;
}
if (!is_dir  !strcmp(base, path)) {
-   replace_dir(buf, git_dir_len, get_git_common_dir());
+   replace_dir(buf, git_dir_len, common_dir);
return;
}
}
@@ -160,7 +165,7 @@ static void adjust_git_path(struct strbuf *buf, int 
git_dir_len)
else if (git_db_env  dir_prefix(base, objects))
replace_dir(buf, git_dir_len + 7, get_object_directory());
else if (git_common_dir_env)
-   update_common_dir(buf, git_dir_len);
+   update_common_dir(buf, git_dir_len, NULL);
 }
 
 static void do_git_path(struct strbuf *buf, const char *fmt, va_list args)
@@ -256,6 +261,8 @@ const char *git_path_submodule(const char *path, const char 
*fmt, ...)
 {
struct strbuf *buf = get_pathname();
const char *git_dir;
+   struct strbuf git_submodule_common_dir = STRBUF_INIT;
+   struct strbuf git_submodule_dir = STRBUF_INIT;
va_list args;
 
strbuf_addstr(buf, path);
@@ -269,11 +276,20 @@ const char *git_path_submodule(const char *path, const 
char *fmt, ...)
strbuf_addstr(buf, git_dir);
}
strbuf_addch(buf, '/');
+   strbuf_addstr(git_submodule_dir, buf-buf);
 
va_start(args, fmt);
strbuf_vaddf(buf, fmt, args);
va_end(args);
+
+   if (get_common_dir_noenv(git_submodule_common_dir, 
git_submodule_dir.buf)) {
+   update_common_dir(buf, git_submodule_dir.len, 
git_submodule_common_dir.buf);
+   }
+
strbuf_cleanup_path(buf);
+
+   strbuf_release(git_submodule_dir);
+   strbuf_release(git_submodule_common_dir);
return buf-buf;
 }
 
diff --git a/setup.c b/setup.c
index 05a8955..45e90c4 100644
--- a/setup.c
+++ b/setup.c
@@ -226,14 +226,21 @@ void verify_non_filename(const char *prefix, const char 
*arg)
 
 int get_common_dir(struct strbuf *sb, const char *gitdir)
 {
+   const char *git_env_common_dir = getenv(GIT_COMMON_DIR_ENVIRONMENT);
+   if (git_env_common_dir) {
+   strbuf_addstr(sb, git_env_common_dir);
+   return 1;
+   } else {
+   return get_common_dir_noenv(sb, gitdir);
+   }
+}
+
+int get_common_dir_noenv(struct strbuf *sb, const char *gitdir)
+{
struct strbuf data = STRBUF_INIT;
struct strbuf path = STRBUF_INIT;
-   const char *git_common_dir = getenv(GIT_COMMON_DIR_ENVIRONMENT);
int ret = 0;
-   if (git_common_dir) {
-   strbuf_addstr(sb, git_common_dir);
-   return 1;
-   }
+
strbuf_addf(path, %s/commondir, gitdir);
if (file_exists(path.buf)) {
if (strbuf_read_file(data, path.buf, 0) = 0)
diff --git a/t/t7410-submodule-checkout-to.sh b/t/t7410-submodule-checkout-to.sh
index 8f30aed..b43391a 100755
--- a/t/t7410-submodule-checkout-to.sh
+++ b/t/t7410-submodule-checkout-to.sh
@@ -47,4 +47,14 

[PATCH v3 3/3] Add GIT_COMMON_DIR to local_repo_env

2014-12-08 Thread Max Kirillov
This is obviously right thing to do, because submodule repository does
not use common directory of super repository.

Suggested-by: Jens Lehmann jens.lehm...@web.de
Signed-off-by: Max Kirillov m...@max630.net
---
 environment.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/environment.c b/environment.c
index 8351007..85ce3c4 100644
--- a/environment.c
+++ b/environment.c
@@ -94,6 +94,7 @@ const char * const local_repo_env[] = {
CONFIG_DATA_ENVIRONMENT,
DB_ENVIRONMENT,
GIT_DIR_ENVIRONMENT,
+   GIT_COMMON_DIR_ENVIRONMENT,
GIT_WORK_TREE_ENVIRONMENT,
GIT_IMPLICIT_WORK_TREE_ENVIRONMENT,
GRAFT_ENVIRONMENT,
-- 
2.2.0.50.gb2b6831

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/3] submodule refactor: use git_path_submodule() in add_submodule_odb()

2014-12-08 Thread Max Kirillov
Signed-off-by: Max Kirillov m...@max630.net
---
 submodule.c | 28 ++--
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/submodule.c b/submodule.c
index 34094f5..4aad3d4 100644
--- a/submodule.c
+++ b/submodule.c
@@ -122,43 +122,35 @@ void stage_updated_gitmodules(void)
 
 static int add_submodule_odb(const char *path)
 {
-   struct strbuf objects_directory = STRBUF_INIT;
struct alternate_object_database *alt_odb;
+   const char* objects_directory;
int ret = 0;
-   const char *git_dir;
 
-   strbuf_addf(objects_directory, %s/.git, path);
-   git_dir = read_gitfile(objects_directory.buf);
-   if (git_dir) {
-   strbuf_reset(objects_directory);
-   strbuf_addstr(objects_directory, git_dir);
-   }
-   strbuf_addstr(objects_directory, /objects/);
-   if (!is_directory(objects_directory.buf)) {
+   objects_directory = git_path_submodule(path, objects/);
+   if (!is_directory(objects_directory)) {
ret = -1;
goto done;
}
+
/* avoid adding it twice */
for (alt_odb = alt_odb_list; alt_odb; alt_odb = alt_odb-next)
-   if (alt_odb-name - alt_odb-base == objects_directory.len 
-   !strncmp(alt_odb-base, objects_directory.buf,
-   objects_directory.len))
+   if (alt_odb-name - alt_odb-base == strlen(objects_directory) 

+   !strcmp(alt_odb-base, objects_directory))
goto done;
 
-   alt_odb = xmalloc(objects_directory.len + 42 + sizeof(*alt_odb));
+   alt_odb = xmalloc(strlen(objects_directory) + 42 + sizeof(*alt_odb));
alt_odb-next = alt_odb_list;
-   strcpy(alt_odb-base, objects_directory.buf);
-   alt_odb-name = alt_odb-base + objects_directory.len;
+   strcpy(alt_odb-base, objects_directory);
+   alt_odb-name = alt_odb-base + strlen(objects_directory);
alt_odb-name[2] = '/';
alt_odb-name[40] = '\0';
alt_odb-name[41] = '\0';
alt_odb_list = alt_odb;
 
/* add possible alternates from the submodule */
-   read_info_alternates(objects_directory.buf, 0);
+   read_info_alternates(objects_directory, 0);
prepare_alt_odb();
 done:
-   strbuf_release(objects_directory);
return ret;
 }
 
-- 
2.2.0.50.gb2b6831

--
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 v3 0/3] Multiple worktrees vs. submodules fixes

2014-12-08 Thread Max Kirillov
On Tue, Dec 09, 2014 at 06:44:40AM +0200, Max Kirillov wrote:
 After discussions I came to basically same as v1.
 
 * Resubmitting the 2 patches which have not been taken to worktrees reroll -
   they fix visible issue. Mostly unchanged except small cleanup in test.
 * Added GIT_COMMON_DIR to local_repo_env. While it is obviously a right
   thing, I wasn't able to observe any change in behavior.
 
 Max Kirillov (3):
   submodule refactor: use git_path_submodule() in add_submodule_odb()
   path: implement common_dir handling in git_path_submodule()
   Add GIT_COMMON_DIR to local_repo_env
 
  cache.h  |  1 +
  environment.c|  1 +
  path.c   | 24 
  setup.c  | 17 -
  submodule.c  | 28 ++--
  t/t7410-submodule-checkout-to.sh | 10 ++
  6 files changed, 54 insertions(+), 27 deletions(-)
 
 -- 
 2.2.0.50.gb2b6831


Should be applied on top of
http://thread.gmane.org/gmane.comp.version-control.git/260387
with _all_ patches included, currently it's df56607dff

-- 
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


<    1   2