{"thread":{"id":"51489","subject":"[PATCH 0/1] Adding git-ignore command, tests, and documentation.","startedAt":"2019-07-17T02:49:37Z","lastAt":"2019-07-18T20:21:43Z","messageCount":4,"participants":["Thurston via GitGitGadget","Thurston Stone via GitGitGadget","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"379001","messageId":"pull.264.git.gitgitgadget@gmail.com","threadId":"51489","inReplyTo":null,"subject":"[PATCH 0/1] Adding git-ignore command, tests, and documentation.","fromName":"Thurston via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-07-17T02:49:33Z","receivedAt":"2019-07-17T02:49:37Z","isPatch":true,"sender":{"key":"name:Thurston","avatar":null},"body":"git-ignore will allow users to quickly add entries to the gitignore files in\nthe repositories.\n\nMany times, I'll have a config file or log file buried in a series of\nsub-directories and find it frustrating to edit the right git ignore with\nthe right relative path to the file that i want to add. This script makes\nadding items to a gitignore file easier.\n\nInstead of managing paths and relative paths such as echo\n\"path/to/the/file.txt\" >../../../../../../.gitignore git ignore\npath/to/the/file.txt No matter what directory that is in, the correct\nrelative path will be added to the gitignore.\n\nThis script will also give the ability to add directories, extention globs,\nand files to any gitignore in parent directories. Furthermore, it allows you\nto easily open the gitignore file in your favorite editor from anywhere\nusing: git ignore --edit\n\nI have been using this script for years and it has made things much easier\nfor me, so I figured I'd contribute.\n\nThurston Stone (1):\n  Adding git ignore command\n\n .gitignore                   |   1 +\n Documentation/git-ignore.txt | 116 ++++++++++++++++++\n Makefile                     |   1 +\n git-ignore.sh                | 222 +++++++++++++++++++++++++++++++++++\n t/t7070-ignore.sh            | 180 ++++++++++++++++++++++++++++\n 5 files changed, 520 insertions(+)\n create mode 100644 Documentation/git-ignore.txt\n create mode 100755 git-ignore.sh\n create mode 100755 t/t7070-ignore.sh\n\n\nbase-commit: 8dca754b1e874719a732bc9ab7b0e14b21b1bc10\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-264%2Ftstone2077%2Fmaster-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-264/tstone2077/master-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/264\n-- \ngitgitgadget\n"},{"id":"379002","messageId":"b0b4034c93c4066605a669536988d0c9ad71f401.1563331772.git.gitgitgadget@gmail.com","threadId":"51489","inReplyTo":"pull.264.git.gitgitgadget@gmail.com","subject":"[PATCH 1/1] Adding git ignore command","fromName":"Thurston Stone via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-07-17T02:49:34Z","receivedAt":"2019-07-17T02:49:40Z","isPatch":true,"sender":{"key":"tstone2077@protonmail.com","avatar":"https://gravatar.com/avatar/02a2a061e5e6f40a1519bc678eb0f601bc6fe9ac4cd5525494a2a4a6626ba569?d=mp&s=160"},"body":"From: Thurston Stone <tstone2077@gmail.com>\n\nThe 'git ignore' command modifies a .gitignore file in your path\neasily. By default, it adds lines to the .gitignore found in the\nroot of your repository. It can, however, add lines to a gitignore\nanywhere inbetween the file(s) passed in and the root of the\nrepository. The lines added to the gitignore can be based on\nfilename, extension, directory, or recursive glob.\n\nAlso, you can easily open the gitignore file using your $EDITOR\nwith 'git ignore --edit'.\n\nThis can make things much easier when ignore files in subdirectories.\nNo longer will you have to run:\necho \"path/to/the/file.txt\" >../../../../../../.gitignore\ninstead:\ngit ignore file.txt\n\nSigned-off-by: Thurston Stone <tstone2077@gmail.com>\n---\n .gitignore                   |   1 +\n Documentation/git-ignore.txt | 116 ++++++++++++++++++\n Makefile                     |   1 +\n git-ignore.sh                | 222 +++++++++++++++++++++++++++++++++++\n t/t7070-ignore.sh            | 180 ++++++++++++++++++++++++++++\n 5 files changed, 520 insertions(+)\n create mode 100644 Documentation/git-ignore.txt\n create mode 100755 git-ignore.sh\n create mode 100755 t/t7070-ignore.sh\n\ndiff --git a/.gitignore b/.gitignore\nindex 4470d7cfc0..fd0707fadf 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -76,6 +76,7 @@\n /git-http-backend\n /git-http-fetch\n /git-http-push\n+/git-ignore\n /git-imap-send\n /git-index-pack\n /git-init\ndiff --git a/Documentation/git-ignore.txt b/Documentation/git-ignore.txt\nnew file mode 100644\nindex 0000000000..df1dfd7a88\n--- /dev/null\n+++ b/Documentation/git-ignore.txt\n@@ -0,0 +1,116 @@\n+git-ignore(1)\n+=============\n+\n+NAME\n+----\n+git-ignore - Easily add entries to your .gitignore file\n+\n+\n+SYNOPSIS\n+--------\n+[verse]\n+'git ignore' [--dry-run | -n] [--ext | -e] [--all-ext | -E] [--dir | -d]\n+\t[--all-file | -a] [--parent-level | -p <parent_level>] pathspec [...]\n+'git ignore' --edit [--parent-level | -p <parent_level>]\n+\n+\n+DESCRIPTION\n+-----------\n+The command modifies a .gitignore file in your path easily. By default,\n+it adds lines to the .gitignore found in the root of your repository. It\n+can, however, add lines to a gitignore anywhere inbetween the file(s)\n+passed in and the root directory. The lines added can be based on\n+filename, extension, directory, or recursive glob.\n+\n+Also, you can easily open the gitignore file using the $EDITOR environment\n+variable.\n+\n+\n+OPTIONS\n+-------\n+<pathspec>...::\n+\tFiles to add to a gitignore. Fileglobs (e.g. `*.c`) can\n+\tbe given to add all matching files.  Also a\n+\tdirectory name can be given to add it to the gitignore\n+\tas well.\n+\n+--edit::\n+\tOpen the appropriate gitignore file in your default editor (using the\n+\t$EDITOR variable). This option can be combined with `--parent-level` based\n+\ton your current working directory.\n+\n+-n::\n+--dry-run::\n+\tDon't actually edit the gitignore(s), just show what changes\n+\twould have taken place.\n+\n+-e::\n+--ext::\n+\tAdd the relative filepath based on extension. If pathspec\n+\treferences path/to/file.log, the added gitignore line would\n+\tbe path/to/*.log.\n+\n+-E::\n+--all-ext::\n+\tAdd a global exclusion of the given extension. If pathspec\n+\treferences path/to/file.log, the added gitignore line would\n+\tbe **/*.log.\n+\n+-d::\n+--dir::\n+\tAdd the contents of the parent directory. If pathspec references\n+\tpath/to/file.log, the added gitignore line would be path/to/*.\n+\n+-a::\n+--all-file::\n+\tAdd a global exclusion of the given filename. If pathspec references\n+\tpath/to/file.log, the added gitignore line would be **/file.log.\n+\n+-p::\n+--parent-level <parent_level>::\n+\tModifications will go to a gitignore located <parent_level>\n+\tdirectories above each of the files passed in. If the number\n+\tof parent levels causes the directory to fall outside of the\n+\troot of the git repository, a warning is printed and the root\n+\tof the repository is used instead. Using a parent-level of 0\n+\twill use the gitignore in the directory of each file passed in.\n+\n++\n+Note that the parent level is calculated for each file passed in. If multiple\n+files are passed in that have different parents at a given parent level, then\n+they will cause separate gitignore files to be written.\n+\n+\n+EXAMPLES\n+--------\n+\n+* Adds all `*.log` files under `tmp` directory\n+and its subdirectories to the gitignore file found at the\n+root of the repository:\n++\n+------------\n+$ pwd\n+/user/test/git_repo/src\n+$ git ignore -e tmp/file.log\n+------------\n++\n+Results in `tmp/*.log` added to /user/test/git_repo/.gitignore\n+\n+\n+* Add the files under the `var/uploaded` directory to the gitignore above\n+\n++\n+------------\n+$ pwd\n+/user/test/git_repo/\n+$ git ignore -d --parent-level=1 www/var/uploaded/\\*\n+------------\n+Results in `var/uploaded/*` added to /user/test/git_repo/www/.gitignore\n+\n+SEE ALSO\n+--------\n+linkgit:gitignore[5]\n+\n+GIT\n+---\n+Part of the linkgit:git[1] suite\ndiff --git a/Makefile b/Makefile\nindex f58bf14c7b..77ad5bd8e2 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -606,6 +606,7 @@ TEST_PROGRAMS_NEED_X =\n unexport CDPATH\n \n SCRIPT_SH += git-bisect.sh\n+SCRIPT_SH += git-ignore.sh\n SCRIPT_SH += git-difftool--helper.sh\n SCRIPT_SH += git-filter-branch.sh\n SCRIPT_SH += git-merge-octopus.sh\ndiff --git a/git-ignore.sh b/git-ignore.sh\nnew file mode 100755\nindex 0000000000..7cdc76caaf\n--- /dev/null\n+++ b/git-ignore.sh\n@@ -0,0 +1,222 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2016, Thurston Stone\n+#\n+# unit test: t7900\n+\n+test -z \"$DDDEBUG\" || set -x\n+\n+_verbose=0\n+\n+SUBDIRECTORY_OK=Yes\n+OPTIONS_KEEPDASHDASH=\n+OPTIONS_STUCKLONG=t\n+# Would be nice to have examples, but rev-parse sees '*' as a symbol to hide everything afterwards\n+#e,ext\t\t add relative path for any file of that type (ex. path/to/*.ext)\n+#E,all-ext\t all files of that extention anywhere (ex. **/*.ext)\n+#d,dir\t\t all files under the parent directory (ex. directory/*)\n+#a,all-file\t all files of that file name (ex. **/filename.ext)\n+OPTIONS_SPEC=\"git ignore [options] [file|glob ...]\n+--\n+ Miscelleneous\n+edit\t\t open the pertinent gitignore with your default text editor (Requires \\$EDITOR to be set)\n+v,verbose\t show verbose output\n+n,dry-run\t do not actually edit any .gitignore files\n+ Determine what files to add to the gitignore(s):\n+e,ext\t\t add relative path for any file of that type\n+E,all-ext\t all files of that extention anywhere\n+d,dir\t\t all files under the parent directory\n+a,all-file\t all files of that file name\n+ Determine what gitignore(s) to use:\n+p,parent-level=  number of parent directories containing the gitignore to edit. Set to 0 to put it in the local directory\"\n+\n+. git-sh-setup\n+. git-sh-i18n\n+\n+write_output () {\n+\tif test $_verbose -eq 1\n+\tthen\n+\tsay $1\n+\tfi\n+}\n+\n+get_git_ignore () {\n+\tdirectory=$1\n+\n+\t# if we don't yet have the repo root directory, get it\n+\tif test -z \"$repo_root\"\n+\tthen\n+\t#First, determine the root of the repository\n+\trepo_root=\"$(git rev-parse --show-toplevel)/\"\n+\twrite_output \"repo_root=$repo_root\"\n+\tfi\n+\n+\t# get the path relative to the repo root\n+\trel_directory=\"${directory#$repo_root}\"\n+\t# if the relative path is the same as it was, try converting it to aa *nix\n+\t# style path\n+\tif test \"$rel_directory\" = \"$directory\"\n+\tthen\n+\t\t# repo root 2 (cygwin-ified path) didn't work\n+\t\t# try the other one\n+\t\twrite_output \"changing repo_root from $repo_root\"\n+\t\t#On windows, this turns to C:\\... instead of /c/... from some other commands\n+\t\trepo_root=$(printf \"$repo_root\" | awk -F\":\" '{ if ($2) print \"/\" tolower($1) $2; else print $1 }')\n+\t\twrite_output \"\tto $repo_root\"\n+\t\trel_directory=\"${directory#$repo_root}\"\n+\tfi\n+\t# default gitignore\n+\tgitignore=\"${repo_root}.gitignore\"\n+\n+\t# ------------------------------------------------\n+\t# Determine the correct git ignore and the path of\n+\t# the file relative to it\n+\t# ------------------------------------------------\n+\tif test $_parent_level -ge 0\n+\tthen\n+\t\tparent=${directory}\n+\t\twrite_output \"parent=${parent}\"\n+\n+\t\tif test $_parent_level -ne 0\n+\t\tthen\n+\t\t\ti=1\n+\t\t\twhile test \"$i\" -le $_parent_level\n+\t\t\tdo\n+\t\t\t\tparent=\"$(dirname \"$parent\")/\"\n+\t\t\t\twrite_output \"parent=${parent}\"\n+\t\t\t\ti=$(($i + 1))\n+\t\t\tdone\n+\t\tfi\n+\t\troot_len=$(printf \"${repo_root}\" | wc -m)\n+\t\tparent_len=$(printf \"${parent}\" | wc -m)\n+\t\tif test $root_len -ge $parent_len\n+\t\tthen\n+\t\t\twrite_output \"root_len(${root_len}) >= parent_len(${parent_len})...\n+\t\t\tuh-oh\"\n+\t\t\tgettextln \"WARNING: Parent directory is outside of the repository\"\n+\t\t\tparent=\"${repo_root}\"\n+\t\telse\n+\t\t\twrite_output \"root_len(${root_len}) < parent_len(${parent_len})...\n+\t\t\tgood\"\n+\t\tfi\n+\t\trel_directory=\"${directory#$parent}\"\n+\t\tgitignore=\"${parent}.gitignore\"\n+\tfi\n+\n+\twrite_output \"rel_directory=${rel_directory}\"\n+\twrite_output \"gitignore=${gitignore}\"\n+\n+}\n+\n+add_ignore () {\n+\t# get the absolute path of the file\n+\tfile=\"$(cd \"$(dirname \"$1\")\"; pwd)/$(basename \"$1\")\"\n+\twrite_output \"file=$file\"\n+\n+\tdirectory=\"$(dirname \"$file\")/\"\n+\twrite_output \"directory=$directory\"\n+\tget_git_ignore \"$directory\"\n+\n+\tfilename=$(basename \"$file\")\n+\twrite_output \"filename=$filename\"\n+\textension=\"${filename##*.}\"\n+\twrite_output \"extension=$extension\"\n+\t# defaault line\n+\tline=\"${rel_directory}${filename}\"\n+\n+\t# ------------------------------------------------\n+\t# Determine the correct line to add to the gitignore\n+\t# based on user inputs\n+\t# ------------------------------------------------\n+\tif test $_ext -eq 1\n+\tthen\n+\t\tline=\"${rel_directory}*.$extension\"\n+\tfi\n+\tif test $_directory -eq 1\n+\tthen\n+\t\tline=\"${rel_directory}*\"\n+\tfi\n+\tif test $_file_anywhere -eq 1\n+\tthen\n+\t\tline=\"**/$filename\"\n+\tfi\n+\tif test $_ext_anywhere -eq 1\n+\tthen\n+\t\tline=\"**/*.$extension\"\n+\tfi\n+\twrite_output \"line=${line}\"\n+\tdryrun=\"\"\n+\tif test $_dry_run -eq 1\n+\tthen\n+\t\tdryrun=\"$(gettext \"DRY-RUN!\")\"\n+\tfi\n+\tsay \"$dryrun $(eval_gettext \"Adding \\$line to \\$gitignore\")\"\n+\tif test $_dry_run -eq 0\n+\tthen\n+\t\techo \"$line\" >>\"$gitignore\"\n+\tfi\n+}\n+\n+_ext=0\n+_directory=0\n+_file_anywhere=0\n+_ext_anywhere=0\n+_parent_level=-1\n+_edit=0\n+_dry_run=0\n+\n+while test $# != 0\n+do\n+\tcase \"$1\" in\n+\t--ext)\n+\t\t_ext=1\n+\t;;\n+\t--all-ext)\n+\t\t_ext_anywhere=1\n+\t;;\n+\t--dir)\n+\t\t_directory=1\n+\t;;\n+\t--all-file)\n+\t\t_file_anywhere=1\n+\t;;\n+\t--parent-level=*)\n+\t\t_parent_level=\"${1#--parent-level=}\"\n+\t\tif ! echo $_parent_level | grep -q '^[0-9]\\+$'\n+\t\tthen\n+\t\t\tgettextln \"ILLEGAL PARAMETER: -p|--parent-level requires a numerical argument\"\n+\t\t\tusage\n+\t\tfi\n+\t;;\n+\t--dry-run)\n+\t\t_dry_run=1\n+\t;;\n+\t--edit)\n+\t\tif test -z $EDITOR\n+\t\tthen\n+\t\t\tgettextln \"ERROR: Shell variable \\$EDITOR must be set\"\n+\t\t\tusage\n+\t\tfi\n+\t\t_edit=1\n+\t;;\n+\t--verbose)\n+\t\t_verbose=1\n+\t;;\n+\t--)\n+\t\tonly_files_left=1\n+\t;;\n+\t*)\n+\t\tif test $only_files_left -eq 1\n+\t\tthen\n+\t\t\tadd_ignore \"$1\"\n+\t\tfi\n+\t;;\n+\tesac\n+\tshift\n+done\n+if test $_edit -eq 1\n+then\n+\tget_git_ignore \"$(pwd)/\"\n+\tgit_editor \"$gitignore\"\n+fi\n+exit 0\ndiff --git a/t/t7070-ignore.sh b/t/t7070-ignore.sh\nnew file mode 100755\nindex 0000000000..4966f62ac2\n--- /dev/null\n+++ b/t/t7070-ignore.sh\n@@ -0,0 +1,180 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2016 Thurston Stone\n+#\n+\n+\n+test_description='check-git-ignore-cmd'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' '\n+\techo a >a &&\n+\tgit add a &&\n+\tgit commit -m\"adding initial files\"\n+'\n+\n+\n+test_expect_success 'ignore at root' '\n+\techo a >ignoreme.txt &&\n+\tDDDEBUG=1 git ignore ignoreme.txt &&\n+\techo \"ignoreme.txt\"  >expect &&\n+\tcat .gitignore >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'ignore in subdir' '\n+\trm .gitignore &&\n+\tmkdir -p \"sub/dir with space\" &&\n+\techo a >\"sub/dir with space/ignoreme.txt\" &&\n+\t(\n+\t\tcd \"sub/dir with space\" &&\n+\t\tDDDEBUG=1 git ignore -v ignoreme.txt\n+\t) &&\n+\techo \"sub/dir with space/ignoreme.txt\"\t>expect &&\n+\tcat .gitignore >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'ignore extentions at root' '\n+\trm .gitignore &&\n+\techo a >ignoreme.txt &&\n+\tDDDEBUG=1 git ignore -v -e ignoreme.txt &&\n+\techo \"*.txt\" >expect &&\n+\tcat .gitignore >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'ignore extentions in subdir' '\n+\trm .gitignore &&\n+\tmkdir -p \"sub/dir with space\" &&\n+\techo a >\"sub/dir with space/ignoreme.txt\" &&\n+\t(\n+\t\tcd \"sub/dir with space\" &&\n+\t\tDDDEBUG=1 git ignore -v -e ignoreme.txt\n+\t) &&\n+\techo \"sub/dir with space/*.txt\" >expect &&\n+\tcat .gitignore >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'ignore extentions anywhere' '\n+\trm .gitignore &&\n+\tmkdir -p \"sub/dir with space\" &&\n+\techo a >\"sub/dir with space/ignoreme.txt\" &&\n+\t(\n+\t\tcd \"sub/dir with space\" &&\n+\t\tDDDEBUG=1 git ignore -v -E ignoreme.txt\n+\t) &&\n+\techo \"**/*.txt\" >expect &&\n+\tcat .gitignore >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'ignore directory' '\n+\trm .gitignore &&\n+\tmkdir -p \"sub/dir with space\" &&\n+\techo a >\"sub/dir with space/ignoreme.txt\" &&\n+\t(\n+\t\tcd \"sub/dir with space\" &&\n+\t\tDDDEBUG=1 git ignore -v -d ignoreme.txt\n+\t) &&\n+\techo \"sub/dir with space/*\" >expect &&\n+\tcat .gitignore >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'ignore filename anywhere' '\n+\trm .gitignore &&\n+\tmkdir -p \"sub/dir with space\" &&\n+\techo a >\"sub/dir with space/ignoreme.txt\" &&\n+\t(\n+\t\tcd \"sub/dir with space\" &&\n+\t\tDDDEBUG=1 git ignore -v -a ignoreme.txt\n+\t) &&\n+\techo \"**/ignoreme.txt\" >expect &&\n+\tcat .gitignore >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'dry run does not write anything' '\n+\trm .gitignore &&\n+\techo a >ignoreme.txt &&\n+\tDDDEBUG=1 git ignore -v -n ignoreme.txt >output &&\n+\tgrep \"^DRY-RUN!\" <output &&\n+\ttest_path_is_missing .gitignore\n+'\n+\n+test_expect_success 'parent-level set to current dir' '\n+\tmkdir -p \"sub/dir with space\" &&\n+\techo a >\"sub/dir with space/ignoreme.txt\" &&\n+\t(\n+\t\tcd \"sub/dir with space\" &&\n+\t\tDDDEBUG=1 git ignore -v -p 0 ignoreme.txt\n+\t) &&\n+\techo \"ignoreme.txt\" >expect &&\n+\tcat \"sub/dir with space/.gitignore\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'parent-level set to dir outside of repo top-level' '\n+\tmkdir -p \"sub/dir with space\" &&\n+\techo a >\"sub/dir with space/ignoreme.txt\" &&\n+\t(\n+\t\tcd \"sub/dir with space\" &&\n+\t\tDDDEBUG=1 git ignore -v -p 2 ignoreme.txt >output\n+\t) &&\n+\tgrep \"^WARNING\" <\"sub/dir with space/output\" &&\n+\techo \"sub/dir with space/ignoreme.txt\" >expect &&\n+\tcat .gitignore >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'parent-level set to mutliple gitignores' '\n+\tmkdir -p \"sub/dir1 with space/test\" &&\n+\techo a >\"sub/dir1 with space/test/ignoreme.txt\" &&\n+\tmkdir -p \"sub/dir2 with space/test\" &&\n+\techo a >\"sub/dir2 with space/test/ignoreme.txt\" &&\n+\tDDDEBUG=1 git ignore -v -p 1 \"sub/dir1 with space/test/ignoreme.txt\" \"sub/dir2 with space/test/ignoreme.txt\" &&\n+\techo \"test/ignoreme.txt\" >expect &&\n+\tcat \"sub/dir1 with space/.gitignore\" >actual &&\n+\ttest_cmp expect actual &&\n+\tcat \"sub/dir2 with space/.gitignore\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+setup_fake_editor () {\n+\twrite_script fake-editor <<-\\EOF\n+set -x\n+file=$1\n+printf \"edited the file like a boss\">\"$1\"\n+EOF\n+}\n+\n+test_set_editor \"$(pwd)/fake-editor\"\n+\n+test_expect_success 'edit root gitignore' '\n+\tsetup_fake_editor &&\n+\tmkdir -p \"sub/dir with space\" &&\n+\t(\n+\t\tcd \"sub/dir with space\" &&\n+\t\tDDDEBUG=1 git ignore -v --edit\n+\t) &&\n+\tprintf \"edited the file like a boss\" >expect &&\n+\tcat .gitignore >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'edit root gitignore using --parent-level' '\n+\tsetup_fake_editor &&\n+\tmkdir -p \"sub/dir with space/test\" &&\n+\t(\n+\t\tcd \"sub/dir with space/test\" &&\n+\t\tDDDEBUG=1 git ignore -p 2 --edit\n+\t) &&\n+\tprintf \"edited the file like a boss\" >expect &&\n+\tcat sub/.gitignore >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_done\n-- \ngitgitgadget\n"},{"id":"379019","messageId":"xmqqmuhc1uw9.fsf@gitster-ct.c.googlers.com","threadId":"51489","inReplyTo":"pull.264.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 0/1] Adding git-ignore command, tests, and documentation.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-07-17T16:35:34Z","receivedAt":"2019-07-17T16:35:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Thurston via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> Instead of managing paths and relative paths such as echo\n> \"path/to/the/file.txt\" >../../../../../../.gitignore git ignore\n> path/to/the/file.txt No matter what directory that is in, the correct\n> relative path will be added to the gitignore.\n\nHmph, do you mean you type something like this?\n\n\t$ cd path/to/the\n\t... work in that deep directory ...\n\t... realize that file.txt in that directory needs ignoring ...\n\t$ echo path/to/the/file.txt >../../../../../../.gitignore\n\nWouldn't this simpler to type and less error prone, as you do not\nhave to count ../?\n\n\t$ cd path/to/the\n\t... work in that deep directory ...\n\t... realize that file.txt in that directory needs ignoring ...\n\t$ echo file.txt >.gitignore\n\n"},{"id":"379078","messageId":"20190718202140.GB22038@sigill.intra.peff.net","threadId":"51489","inReplyTo":"xmqqmuhc1uw9.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH 0/1] Adding git-ignore command, tests, and documentation.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-07-18T20:21:40Z","receivedAt":"2019-07-18T20:21:43Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jul 17, 2019 at 09:35:34AM -0700, Junio C Hamano wrote:\n\n> \"Thurston via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> \n> > Instead of managing paths and relative paths such as echo\n> > \"path/to/the/file.txt\" >../../../../../../.gitignore git ignore\n> > path/to/the/file.txt No matter what directory that is in, the correct\n> > relative path will be added to the gitignore.\n> \n> Hmph, do you mean you type something like this?\n> \n> \t$ cd path/to/the\n> \t... work in that deep directory ...\n> \t... realize that file.txt in that directory needs ignoring ...\n> \t$ echo path/to/the/file.txt >../../../../../../.gitignore\n> \n> Wouldn't this simpler to type and less error prone, as you do not\n> have to count ../?\n> \n> \t$ cd path/to/the\n> \t... work in that deep directory ...\n> \t... realize that file.txt in that directory needs ignoring ...\n> \t$ echo file.txt >.gitignore\n\nIt's also much more efficient, at least with our current implementation,\nas we do not have to worry about matching this entry when we are dealing\nwith /some/other/path. See [1] for a pathological case.\n\nI see \"with our current implementation\" because I could imagine a world\nin which we have a more trie-like structure for non-wildcard patterns.\nBut I don't think anybody is working on such a thing.\n\n-Peff\n\n[1] https://public-inbox.org/git/20120329211136.GA1112@sigill.intra.peff.net/\n"}]}