Merge branch 'master' into next

* master:
  update-server-info: Shorten read_pack_info_file()
  git add: Add --ignore-missing to SYNOPSIS
  git submodule add: Remove old docs about implicit -f
  git submodule add: Require the new --force option to add ignored paths
  Documentation: Explain git-mergetool's use of temporary files
  git-svn: write memoized data explicitly to avoid Storable bug
  git add: Add the "--ignore-missing" option for the dry run
This commit is contained in:
Junio C Hamano
2010-07-19 11:50:42 -07:00
11 changed files with 110 additions and 29 deletions

View File

@@ -10,7 +10,8 @@ SYNOPSIS
[verse]
'git add' [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p]
[--edit | -e] [--all | [--update | -u]] [--intent-to-add | -N]
[--refresh] [--ignore-errors] [--] [<filepattern>...]
[--refresh] [--ignore-errors] [--ignore-missing] [--]
[<filepattern>...]
DESCRIPTION
-----------
@@ -57,7 +58,8 @@ OPTIONS
-n::
--dry-run::
Don't actually add the file(s), just show if they exist.
Don't actually add the file(s), just show if they exist and/or will
be ignored.
-v::
--verbose::
@@ -131,6 +133,12 @@ subdirectories.
them, do not abort the operation, but continue adding the
others. The command shall still exit with non-zero status.
--ignore-missing::
This option can only be used together with --dry-run. By using
this option the user can check if any of the given files would
be ignored, no matter if they are already present in the work
tree or not.
\--::
This option can be used to separate command-line options from
the list of files, (useful when filenames might be mistaken

View File

@@ -72,6 +72,16 @@ success of the resolution after the custom tool has exited.
This is the default behaviour; the option is provided to
override any configuration settings.
TEMPORARY FILES
---------------
`git mergetool` creates `*.orig` backup files while resolving merges.
These are safe to remove once a file has been merged and its
`git mergetool` session has completed.
Setting the `mergetool.keepBackup` configuration variable to `false`
causes `git mergetool` to automatically remove the backup as files
are successfully merged.
Author
------
Written by Theodore Y Ts'o <tytso@mit.edu>

View File

@@ -9,7 +9,7 @@ git-submodule - Initialize, update or inspect submodules
SYNOPSIS
--------
[verse]
'git submodule' [--quiet] add [-b branch]
'git submodule' [--quiet] add [-b branch] [-f|--force]
[--reference <repository>] [--] <repository> [<path>]
'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]
'git submodule' [--quiet] init [--] [<path>...]
@@ -95,10 +95,6 @@ is the superproject and submodule repositories will be kept
together in the same relative location, and only the
superproject's URL needs to be provided: git-submodule will correctly
locate the submodule using the relative URL in .gitmodules.
+
The submodule will be added with "git add --force <path>". I.e. git
doesn't care if the new path is in a `gitignore`. Your invocation of
"git submodule add" is considered enough to override it.
status::
Show the status of the submodules. This will print the SHA-1 of the
@@ -187,6 +183,11 @@ OPTIONS
--branch::
Branch of repository to add as submodule.
-f::
--force::
This option is only valid for the add command.
Allow adding an otherwise ignored submodule path.
--cached::
This option is only valid for status and summary commands. These
commands typically use the commit found in the submodule HEAD, but

View File

@@ -310,7 +310,7 @@ static const char ignore_error[] =
"The following paths are ignored by one of your .gitignore files:\n";
static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
static int ignore_add_errors, addremove, intent_to_add;
static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;
static struct option builtin_add_options[] = {
OPT__DRY_RUN(&show_only),
@@ -325,6 +325,7 @@ static struct option builtin_add_options[] = {
OPT_BOOLEAN('A', "all", &addremove, "add all, noticing removal of tracked files"),
OPT_BOOLEAN( 0 , "refresh", &refresh_only, "don't add, only refresh the index"),
OPT_BOOLEAN( 0 , "ignore-errors", &ignore_add_errors, "just skip files which cannot be added because of errors"),
OPT_BOOLEAN( 0 , "ignore-missing", &ignore_missing, "check if - even missing - files are ignored in dry run"),
OPT_END(),
};
@@ -385,6 +386,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
if (addremove && take_worktree_changes)
die("-A and -u are mutually incompatible");
if (!show_only && ignore_missing)
die("Option --ignore-missing can only be used together with --dry-run");
if ((addremove || take_worktree_changes) && !argc) {
static const char *here[2] = { ".", NULL };
argc = 1;
@@ -441,9 +444,14 @@ int cmd_add(int argc, const char **argv, const char *prefix)
seen = find_used_pathspec(pathspec);
for (i = 0; pathspec[i]; i++) {
if (!seen[i] && pathspec[i][0]
&& !file_exists(pathspec[i]))
die("pathspec '%s' did not match any files",
pathspec[i]);
&& !file_exists(pathspec[i])) {
if (ignore_missing) {
if (excluded(&dir, pathspec[i], DT_UNKNOWN))
dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i]));
} else
die("pathspec '%s' did not match any files",
pathspec[i]);
}
}
free(seen);
}

2
dir.c
View File

@@ -453,7 +453,7 @@ static struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathna
return dir->entries[dir->nr++] = dir_entry_new(pathname, len);
}
static struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len)
struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len)
{
if (!cache_name_is_other(pathname, len))
return NULL;

1
dir.h
View File

@@ -72,6 +72,7 @@ extern int read_directory(struct dir_struct *, const char *path, int len, const
extern int excluded_from_list(const char *pathname, int pathlen, const char *basename,
int *dtype, struct exclude_list *el);
extern int excluded(struct dir_struct *, const char *, int *);
struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len);
extern int add_excludes_from_file_to_list(const char *fname, const char *base, int baselen,
char **buf_p, struct exclude_list *which, int check_index);
extern void add_excludes_from_file(struct dir_struct *, const char *fname);

View File

@@ -5,7 +5,7 @@
# Copyright (c) 2007 Lars Hjemli
dashless=$(basename "$0" | sed -e 's/-/ /')
USAGE="[--quiet] add [-b branch] [--reference <repository>] [--] <repository> [<path>]
USAGE="[--quiet] add [-b branch] [-f|--force] [--reference <repository>] [--] <repository> [<path>]
or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]
or: $dashless [--quiet] init [--] [<path>...]
or: $dashless [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
@@ -19,6 +19,7 @@ require_work_tree
command=
branch=
force=
reference=
cached=
recursive=
@@ -133,6 +134,9 @@ cmd_add()
branch=$2
shift
;;
-f | --force)
force=$1
;;
-q|--quiet)
GIT_QUIET=1
;;
@@ -201,6 +205,14 @@ cmd_add()
git ls-files --error-unmatch "$path" > /dev/null 2>&1 &&
die "'$path' already exists in the index"
if test -z "$force" && ! git add --dry-run --ignore-missing "$path" > /dev/null 2>&1
then
echo >&2 "The following path is ignored by one of your .gitignore files:" &&
echo >&2 $path &&
echo >&2 "Use -f if you really want to add it."
exit 1
fi
# perhaps the path exists and is already a git repo, else clone it
if test -e "$path"
then
@@ -234,7 +246,7 @@ cmd_add()
) || die "Unable to checkout submodule '$path'"
fi
git add --force "$path" ||
git add $force "$path" ||
die "Failed to add submodule '$path'"
git config -f .gitmodules submodule."$path".path "$path" &&

View File

@@ -3169,6 +3169,22 @@ sub has_no_changes {
LIST_CACHE => 'FAULT',
;
}
sub unmemoize_svn_mergeinfo_functions {
return if not $memoized;
$memoized = 0;
Memoize::unmemoize 'lookup_svn_merge';
Memoize::unmemoize 'check_cherry_pick';
Memoize::unmemoize 'has_no_changes';
}
}
END {
# Force cache writeout explicitly instead of waiting for
# global destruction to avoid segfault in Storable:
# http://rt.cpan.org/Public/Bug/Display.html?id=36087
unmemoize_svn_mergeinfo_functions();
}
sub parents_exclude {

View File

@@ -113,11 +113,8 @@ static int read_pack_info_file(const char *infofile)
goto out_stale;
break;
case 'D': /* we used to emit D but that was misguided. */
goto out_stale;
break;
case 'T': /* we used to emit T but nobody uses it. */
goto out_stale;
break;
default:
error("unrecognized: %s", line);
break;

View File

@@ -260,4 +260,29 @@ test_expect_success '"add non-existent" should fail' '
! (git ls-files | grep "non-existent")
'
test_expect_success 'git add --dry-run of existing changed file' "
echo new >>track-this &&
git add --dry-run track-this >actual 2>&1 &&
echo \"add 'track-this'\" | test_cmp - actual
"
test_expect_success 'git add --dry-run of non-existing file' "
echo ignored-file >>.gitignore &&
! (git add --dry-run track-this ignored-file >actual 2>&1) &&
echo \"fatal: pathspec 'ignored-file' did not match any files\" | test_cmp - actual
"
cat >expect <<EOF
The following paths are ignored by one of your .gitignore files:
ignored-file
Use -f if you really want to add them.
fatal: no files added
add 'track-this'
EOF
test_expect_success 'git add --dry-run --ignore-missing of non-existing file' '
!(git add --dry-run --ignore-missing track-this ignored-file >actual 2>&1) &&
test_cmp expect actual
'
test_done

View File

@@ -86,25 +86,28 @@ test_expect_success 'submodule add' '
test_cmp empty untracked
'
test_expect_success 'submodule add to .gitignored path' '
echo "refs/heads/master" >expect &&
>empty &&
test_expect_success 'submodule add to .gitignored path fails' '
(
cd addtest-ignore &&
cat <<-\EOF >expect &&
The following path is ignored by one of your .gitignore files:
submod
Use -f if you really want to add it.
EOF
# Does not use test_commit due to the ignore
echo "*" > .gitignore &&
git add --force .gitignore &&
git commit -m"Ignore everything" &&
git submodule add "$submodurl" submod &&
git submodule init
) &&
! git submodule add "$submodurl" submod >actual 2>&1 &&
test_cmp expect actual
)
'
rm -f heads head untracked &&
inspect addtest/submod ../.. &&
test_cmp expect heads &&
test_cmp expect head &&
test_cmp empty untracked
test_expect_success 'submodule add to .gitignored path with --force' '
(
cd addtest-ignore &&
git submodule add --force "$submodurl" submod
)
'
test_expect_success 'submodule add --branch' '