'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
'update' => "git pull --ff-only",
'update_rebase' => "git pull --rebase=merges",
+ 'update_stash' => "git pull --rebase=merges --autostash",
'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)",
'post_update' => "git submodule update --init --recursive",
'controldir' => ".git",
'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
'update' => "git pull --ff-only",
'update_rebase' => "git pull --rebase=merges",
+ 'update_stash' => "git pull --rebase=merges --autostash",
'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)",
'post_update' => "git submodule update --init --recursive",
'controldir' => ".git",
# src-git: pull broken
# src-cpy: broken if `basename $src` != $name
-sub update_feed_via($$$$$$) {
+sub update_feed_via($$$$$$$) {
my $type = shift;
my $name = shift;
my $src = shift;
my $relocate = shift;
my $force = shift;
my $rebase = shift;
+ my $stash = shift;
my $m = $update_method{$type};
my $localpath = "./feeds/$name";
if ($rebase && exists $m->{'update_rebase'}) {
$update_cmd = $m->{'update_rebase'};
}
+ if ($stash && exists $m->{'update_stash'}) {
+ $update_cmd = $m->{'update_stash'};
+ }
system("cd '$safepath'; $update_cmd") == 0 or return 1;
}
if ($m->{'post_update'}) {
return 0;
}
-sub update_feed($$$$$)
+sub update_feed($$$$$$)
{
my $type=shift;
my $name=shift;
my $src=shift;
my $force_update=shift;
my $rebase_update=shift;
+ my $stash_update=shift;
my $force_relocate=update_location( $name, "@$src" );
my $rv=0;
my $failed = 1;
foreach my $feedsrc (@$src) {
warn "Updating feed '$name' from '$feedsrc' ...\n";
- if (update_feed_via($type, $name, $feedsrc, $force_relocate, $force_update, $rebase_update) != 0) {
+ if (update_feed_via($type, $name, $feedsrc, $force_relocate, $force_update, $rebase_update, $stash_update) != 0) {
if ($force_update) {
$rv=1;
$failed=0;
$ENV{SCAN_COOKIE} = $$;
$ENV{OPENWRT_VERBOSE} = 's';
- getopts('ahifr', \%opts);
+ getopts('ahifrs', \%opts);
%argv_feeds = map { $_ => 1 } @ARGV;
if ($opts{h}) {
return 0;
}
- if ($opts{f} && $opts{r}) {
- warn "Force and rebase are incompatible update options.\n";;
+ if ($opts{f} && ($opts{r} || $opts{s})) {
+ warn "Force and rebase/stash are incompatible update options.\n";;
return 1;
}
my ($type, $name, $src) = @$feed;
next unless $#ARGV == -1 or $opts{a} or $argv_feeds{$name};
if (not $opts{i}) {
- update_feed($type, $name, $src, $opts{f}, $opts{r}) == 0 or $failed=1;
+ update_feed($type, $name, $src, $opts{f}, $opts{r}, $opts{s}) == 0 or $failed=1;
}
push @index_feeds, $name;
}
Options:
-a : Update all feeds listed within feeds.conf. Otherwise the specified feeds will be updated.
-r : Update by rebase. (git only. Useful if local commits exist)
+ -s : Update by rebase and autostash. (git only. Useful if local commits and uncommited changes exist)
-i : Recreate the index only. No feed update from repository is performed.
-f : Force updating feeds even if there are changed, uncommitted files.