git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Configurable filename for what is now .gitignore
@ 2014-08-30  3:33 Bostjan Skufca
  2014-08-30  5:43 ` Jonathan Nieder
  0 siblings, 1 reply; 6+ messages in thread
From: Bostjan Skufca @ 2014-08-30  3:33 UTC (permalink / raw)
  To: git

Hi there,

I created a patch which makes ".gitignore" filename configurabe.
Preliminary diff is pasted below.

My question is:
Would something like this be acceptable for inclusion?
(providing documentation and test cases will be done too, of course)

See "Motivation" part below for additional explanation.

Possible downsides:
- default filename .gitignore is kept, so there is no issue here, if
this new config option is not changed
- increased support questions, but I think generally people would not
change this setting without having a good reason


Motivation:
Git is great for tracking code development, but when deploying
mentioned code by using git itself, various configuration files must
be created additionally, which are normally .gitignored, for various
reasons (code portability, sensitive data, etc). There is currently no
simple way of tracking changes to those critical configuration files
(at least none that I am aware of).

One way to approach this would be tracking those changes in separate
git repository. It is possible to create this second repo outside of
code repository. But this gets messy very fast (you still need to
create symlinks in code repository, or sth).

It would be splendid if this configuration tracking repository could
be created inside code repository, but in a "separate namespace".
(I've just found out that "namespaces" word is already used for
different concept in git 2.1.x, so let's call it "dirspace" in this
discussion).

Separate dirspace is currently possible for ".git" directory via
GIT_DIR environment variable. Adding possibility of using
differently-named .gitignore files is first step for dirspaces,
.gitmodules and .gitattributes are another two filenames that would
need to be made configurable.

I can imagine a tiny tool, let's call it "gitsth". When called, sets
GIT_DIR from .git to .gitsth, and in .gitsth/config configures
alternate filenames for .gitignore, .gitmodules and .gitattributes to
.gitignoreSTH, .gitmodulesSTH and .gitattrSTH (for example). This
.gitignoreSTH could then be used to ignore all files except
configuration files that need to be tracked.

That is just my imaginative usecase. Think of it as sort of
overlay-git. Git would only need to provide tools for it, so that on
top of those tools new solutions could be created. Other usecases
would probably pop up sooner or later.


Thank you for your opinion,
b.


Readable diff format: http://pastiebin.com/53ff8747b97f1
Actual patch:
(redacted, as vger swallowed two sending tries with a "250 2.7.1 Looks
like Linux source DIFF email.." response)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Configurable filename for what is now .gitignore
  2014-08-30  3:33 Configurable filename for what is now .gitignore Bostjan Skufca
@ 2014-08-30  5:43 ` Jonathan Nieder
  2014-08-31  1:55   ` Bostjan Skufca
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Nieder @ 2014-08-30  5:43 UTC (permalink / raw)
  To: Bostjan Skufca; +Cc: git

Hi,

Bostjan Skufca wrote:

> Git is great for tracking code development, but when deploying
> mentioned code by using git itself, various configuration files must
> be created additionally, which are normally .gitignored, for various
> reasons (code portability, sensitive data, etc). There is currently no
> simple way of tracking changes to those critical configuration files
> (at least none that I am aware of).
>
> One way to approach this would be tracking those changes in separate
> git repository.

Have you seen zit
<https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools#Zit>?

Curious,
Jonathan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Configurable filename for what is now .gitignore
  2014-08-30  5:43 ` Jonathan Nieder
@ 2014-08-31  1:55   ` Bostjan Skufca
  2014-09-01 20:30     ` Bostjan Skufca
  0 siblings, 1 reply; 6+ messages in thread
From: Bostjan Skufca @ 2014-08-31  1:55 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git

Hi Jonathan,

nope, haven't seen zit before, it does partly what I would need, but
just for one file at a time (a "bit" awkward) and not really portable
(git clone will not clone .FILE.git/exclude, for example).

Anyway, do you think that a patch which makes .gitignore filename
configurable would be appropriate for inclusion in future git
releases?

b.



On 30 August 2014 07:43, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Hi,
>
> Bostjan Skufca wrote:
>
>> Git is great for tracking code development, but when deploying
>> mentioned code by using git itself, various configuration files must
>> be created additionally, which are normally .gitignored, for various
>> reasons (code portability, sensitive data, etc). There is currently no
>> simple way of tracking changes to those critical configuration files
>> (at least none that I am aware of).
>>
>> One way to approach this would be tracking those changes in separate
>> git repository.
>
> Have you seen zit
> <https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools#Zit>?
>
> Curious,
> Jonathan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Configurable filename for what is now .gitignore
  2014-08-31  1:55   ` Bostjan Skufca
@ 2014-09-01 20:30     ` Bostjan Skufca
  2014-09-01 23:33       ` Duy Nguyen
  0 siblings, 1 reply; 6+ messages in thread
From: Bostjan Skufca @ 2014-09-01 20:30 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git

I see another crux of the problem.

There is currently no way to transfer/share repository configuration
between clones.
(Or is there? Could this be done with attributes? Probably not...)

This is a bit awkward.
Are there any plans to provide such functionality? Pros/cons?

(It should be limited in scope of course, to provide adequate security
for all parties involved.)


Thanks for sharing your opinion,
b.


PS: For those that did not follow this small thread, here is an
example use case to illustrate the problem:

1. I patch git to support custom filename for .gitignore
2. I reconfigure it in my repository clone (i.e. change it to look for
.gitexclude files)
2a. This is configured in .git/config, for example as
core.excludesDefaultFilename
3. I can commit changes to repository code, namely a change which
renames .gitignore(s) to .gitexclude(s) (which restores correct
exclusion pattern parsing)
4. When I push, only .gitignore rename to .gitexclude goes upstream.
Info about required usage of .gitexclude instead of .gitignore stays
in my repo clone.
5. When someone pulls, they have messed up "git status" output until
they manually set the same setting in their repo clone (using
.gitexclude instead of .gitignore)


On 31 August 2014 03:55, Bostjan Skufca <bostjan@a2o.si> wrote:
> Hi Jonathan,
>
> nope, haven't seen zit before, it does partly what I would need, but
> just for one file at a time (a "bit" awkward) and not really portable
> (git clone will not clone .FILE.git/exclude, for example).
>
> Anyway, do you think that a patch which makes .gitignore filename
> configurable would be appropriate for inclusion in future git
> releases?
>
> b.
>
>
>
> On 30 August 2014 07:43, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> Hi,
>>
>> Bostjan Skufca wrote:
>>
>>> Git is great for tracking code development, but when deploying
>>> mentioned code by using git itself, various configuration files must
>>> be created additionally, which are normally .gitignored, for various
>>> reasons (code portability, sensitive data, etc). There is currently no
>>> simple way of tracking changes to those critical configuration files
>>> (at least none that I am aware of).
>>>
>>> One way to approach this would be tracking those changes in separate
>>> git repository.
>>
>> Have you seen zit
>> <https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools#Zit>?
>>
>> Curious,
>> Jonathan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Configurable filename for what is now .gitignore
  2014-09-01 20:30     ` Bostjan Skufca
@ 2014-09-01 23:33       ` Duy Nguyen
  2014-09-04 20:33         ` Bostjan Skufca
  0 siblings, 1 reply; 6+ messages in thread
From: Duy Nguyen @ 2014-09-01 23:33 UTC (permalink / raw)
  To: Bostjan Skufca; +Cc: Jonathan Nieder, Git Mailing List

On Tue, Sep 2, 2014 at 3:30 AM, Bostjan Skufca <bostjan@a2o.si> wrote:
> There is currently no way to transfer/share repository configuration
> between clones.

See http://article.gmane.org/gmane.comp.version-control.git/216624
-- 
Duy

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Configurable filename for what is now .gitignore
  2014-09-01 23:33       ` Duy Nguyen
@ 2014-09-04 20:33         ` Bostjan Skufca
  0 siblings, 0 replies; 6+ messages in thread
From: Bostjan Skufca @ 2014-09-04 20:33 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Jonathan Nieder, Git Mailing List

I see, tnx for the pointer.

Would inclusion of this patch be viable option then?


Patch below, it is possible to look at it here to:

Patch: https://github.com/teonsystems/git/commit/27449825ff4d7bb3eecb5a3e32692aaf1ab1a026
Branch: https://github.com/teonsystems/git/commits/feature/configurable-gitignore-filename



commit 27449825ff4d7bb3eecb5a3e32692aaf1ab1a026
Author: Bostjan Skufca <bostjan@a2o.si>
Date:   Thu Sep 4 20:20:30 2014 +0000

    .gitignore: make '.gitignore' filename configurable

    When using git with detached work tree and .git directory,
    it is currently impossible to use multiple git repositories
    with the same workdir, as .gitignore is always parsed.

    This feature keeps the original '.gitignore' file as default
    at almost no performance penalty, and enables reconfiguring
    git to use alternate filename when obtaining per-dir exclusion
    patterns.

diff --git a/Documentation/config.txt b/Documentation/config.txt
index c55c22a..1c63b13 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -507,6 +507,17 @@ be delta compressed, but larger binary media
files won't be.
 +
 Common unit suffixes of 'k', 'm', or 'g' are supported.

+core.excludesperdirfilename::
+ By default, Git checks for presence of .gitignore files to read
+ exclude patterns from. This option enables the customization of
+ per-dir exclude patterns filename that is by default called
+ '.gitignore', to arbitrary filename.
++
+This setting is not implicitly distributed when transferring
+changes between repository clones. In order to achieve identical
+behaviour in all repository clones, each repository clone must
+set this option to the same value.
+
 core.excludesfile::
  In addition to '.gitignore' (per-directory) and
  '.git/info/exclude', Git looks into this file for patterns
diff --git a/cache.h b/cache.h
index 4d5b76c..ff952b4 100644
--- a/cache.h
+++ b/cache.h
@@ -392,6 +392,7 @@ static inline enum object_type
object_type(unsigned int mode)
 #define NO_REPLACE_OBJECTS_ENVIRONMENT "GIT_NO_REPLACE_OBJECTS"
 #define GITATTRIBUTES_FILE ".gitattributes"
 #define INFOATTRIBUTES_FILE "info/attributes"
+#define GITIGNORE_FILE ".gitignore"
 #define ATTRIBUTE_MACRO_PREFIX "[attr]"
 #define GIT_NOTES_REF_ENVIRONMENT "GIT_NOTES_REF"
 #define GIT_NOTES_DEFAULT_REF "refs/notes/commits"
@@ -1423,6 +1424,7 @@ extern int check_pager_config(const char *cmd);

 extern const char *editor_program;
 extern const char *askpass_program;
+extern const char *excludes_per_dir_filename;
 extern const char *excludes_file;

 /* base85 */
diff --git a/config.c b/config.c
index a191328..da80556 100644
--- a/config.c
+++ b/config.c
@@ -847,6 +847,9 @@ static int git_default_core_config(const char
*var, const char *value)
  if (!strcmp(var, "core.askpass"))
  return git_config_string(&askpass_program, var, value);

+ if (!strcmp(var, "core.excludesperdirfilename"))
+ return git_config_string(&excludes_per_dir_filename, var, value);
+
  if (!strcmp(var, "core.excludesfile"))
  return git_config_pathname(&excludes_file, var, value);

diff --git a/dir.c b/dir.c
index bd274a7..8b429c3 100644
--- a/dir.c
+++ b/dir.c
@@ -1624,7 +1624,12 @@ void setup_standard_excludes(struct dir_struct *dir)
  const char *path;
  char *xdg_path;

- dir->exclude_per_dir = ".gitignore";
+ if (excludes_per_dir_filename) {
+ dir->exclude_per_dir = excludes_per_dir_filename;
+ } else {
+ dir->exclude_per_dir = GITIGNORE_FILE;
+ }
+
  path = git_path("info/exclude");
  if (!excludes_file) {
  home_config_paths(NULL, &xdg_path, "ignore");
diff --git a/environment.c b/environment.c
index 565f652..0d48ef9 100644
--- a/environment.c
+++ b/environment.c
@@ -43,6 +43,7 @@ const char *pager_program;
 int pager_use_color = 1;
 const char *editor_program;
 const char *askpass_program;
+const char *excludes_per_dir_filename;
 const char *excludes_file;
 enum auto_crlf auto_crlf = AUTO_CRLF_FALSE;
 int check_replace_refs = 1;
diff --git a/t/t7515-status-changed-gitignore-filename.sh
b/t/t7515-status-changed-gitignore-filename.sh
new file mode 100755
index 0000000..ed7de42
--- /dev/null
+++ b/t/t7515-status-changed-gitignore-filename.sh
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+test_description='status with changed default .gitignore filename'
+. ./test-lib.sh
+
+
+#
+# Check if only single file is in 'untracked' state: file2
+# file1 is excluded by ignore pattern in .gitignore (default)
+#
+test_expect_success 'status with default .gitignore filename' '
+ mkdir repo-default &&
+ (cd repo-default && git init &&
+ echo "/file1" > .gitignore  &&
+ git add .gitignore &&
+ touch file1 &&
+ touch file2 &&
+ COUNT_UNTRACKED=`git status | grep -P "^\t" | grep -P -v "^\tnew
file:" | grep -c .` &&
+ if [ "$COUNT_UNTRACKED" == "1" ]; then
+  true
+ else
+  false
+ fi
+ )
+'
+
+
+#
+# Check if only single file is in 'untracked' state: file2
+# file1 is excluded by ignore pattern in .gitexclude (modified
default ignore filename)
+#
+test_expect_success 'status with .gitignore filename reconfigured to
.gitexclude' '
+ mkdir repo-modified &&
+ (cd repo-modified && git init &&
+ git config --add core.excludesperdirfilename .gitexclude &&
+ echo "/file1" > .gitexclude  &&
+ git add .gitexclude &&
+ touch file1 &&
+ touch file2 &&
+ COUNT_UNTRACKED=`git status | grep -P "^\t" | grep -P -v "^\tnew
file:" | grep -c .` &&
+ if [ "$COUNT_UNTRACKED" == "1" ]; then
+  true
+ else
+  false
+ fi
+ )
+'
+
+
+#
+# Check if .gitignore is ignored when default exclude filename is changed
+# file1 is excluded by ignore pattern in .gitexclude (modified
default ignore filename)
+#
+test_expect_success 'ignore .gitignore when reconfigured to use .gitexclude' '
+ mkdir repo-modified-failure &&
+ (cd repo-modified-failure && git init &&
+ git config --add core.excludesperdirfilename .gitexclude &&
+ echo "/file1" > .gitignore  &&
+ git add .gitignore &&
+ touch file1 &&
+ touch file2 &&
+ COUNT_UNTRACKED=`git status | grep -P "^\t" | grep -P -v "^\tnew
file:" | grep -c .` &&
+ if [ "$COUNT_UNTRACKED" == "2" ]; then
+  true
+ else
+  false
+ fi
+ )
+'
+
+
+test_done


b.


On 2 September 2014 01:33, Duy Nguyen <pclouds@gmail.com> wrote:
> On Tue, Sep 2, 2014 at 3:30 AM, Bostjan Skufca <bostjan@a2o.si> wrote:
>> There is currently no way to transfer/share repository configuration
>> between clones.
>
> See http://article.gmane.org/gmane.comp.version-control.git/216624
> --
> Duy

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-09-04 20:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-30  3:33 Configurable filename for what is now .gitignore Bostjan Skufca
2014-08-30  5:43 ` Jonathan Nieder
2014-08-31  1:55   ` Bostjan Skufca
2014-09-01 20:30     ` Bostjan Skufca
2014-09-01 23:33       ` Duy Nguyen
2014-09-04 20:33         ` Bostjan Skufca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).