Commit 00d2ae89 authored by Michael Pyne's avatar Michael Pyne

git: Improve detection of local changes.

libgpg-error currently fails to update with kdesrc-build, ultimately due
to git-rebase complaining that there are local changes that need to be
stashed or reverted first.

These local changes are inherent to the libgpg-error build process, but
even so, kdesrc-build *does* check for local changes and stashes them
automatically.

But it turns out the current check from git of whether there are local
changes (using git-diff) gives a 'no changes' answer with libgpg-error's
modifications. So git-diff thinks there's no change, but git-rebase
thinks there is a change.

git-status --short gives an answer matching git-rebase, so switch to
that instead. git-status also gives answers for both the index and the
working tree at the same time to the updated code is even a bit shorter
now.
parent 99c87f49
Pipeline #5003 passed with stage
in 1 minute and 34 seconds
......@@ -538,29 +538,15 @@ sub stashAndUpdate
my $module = $self->module();
my $date = strftime ("%F-%R", gmtime()); # ISO Date, hh:mm time
# To find out if we should stash, we just use git diff --quiet, twice to
# account for the index and the working dir.
# Note: Don't use safe_system, as the error code is stripped to the exit code
my $status = pretending() ? 0 : system('git', 'diff', '--quiet');
if ($status == -1 || $status & 127) {
croak_runtime("$module doesn't appear to be a git module.");
}
my $needsStash = 0;
if ($status && !_hasSubmodules()) {
# There are local changes.
$needsStash = 1;
}
else {
$status = pretending() ? 0 : system('git', 'diff', '--cached', '--quiet');
if ($status == -1 || $status & 127) {
croak_runtime("$module doesn't appear to be a git module.");
}
else {
$needsStash = ($status != 0);
}
}
# To find out if we should stash, we use git-status in its short mode which
# is intended to be scriptable and returns information on both the index
# and the working dir in one command.
my $status = 1;
my $needsStash =
!pretending() &&
(scalar filter_program_output(
undef, # don't filter output
qw(git status --short --untracked-files=no))) > 0;
if ($needsStash) {
info ("\tLocal changes detected, stashing them away...");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment