@@ -435,7 +435,20 @@ def commit():
435
435
popen ([git_cmd , 'commit' , '-a' ] + (['-v' ] if verbose else ['-q' ]))
436
436
437
437
def push (repo , all = None ):
438
- popen ([git_cmd , 'push' ] + (['--all' ] if all else []) + (['-v' ] if verbose else ['-q' ]))
438
+ if all :
439
+ popen ([git_cmd , 'push' , '--all' ] + (['-v' ] if verbose else ['-q' ]))
440
+ else :
441
+ remote = Git .getremote ()
442
+ branch = Git .getbranch ()
443
+ if remote and branch :
444
+ popen ([git_cmd , 'push' , remote , branch ] + (['-v' ] if verbose else ['-q' ]))
445
+ else :
446
+ err = "Unable to push outgoing changes for \" %s\" in \" %s\" .\n " % (repo .name , repo .path )
447
+ if not remote :
448
+ error (err + "The local repository is not associated with a remote one.\n " , 1 )
449
+ if not branch :
450
+ error (err + "Working set is not on a branch.\n " , 1 )
451
+
439
452
440
453
def pull (repo ):
441
454
popen ([git_cmd , 'fetch' , '--all' ] + (['-v' ] if verbose else ['-q' ]))
@@ -467,15 +480,8 @@ def untracked():
467
480
return pquery ([git_cmd , 'ls-files' , '--others' , '--exclude-standard' ]).splitlines ()
468
481
469
482
def outgoing ():
470
- # Find the default remote
471
- remote = None
472
- remotes = Git .getremotes ('push' )
473
- for r in remotes :
474
- remote = r [0 ]
475
- # Prefer origin which is the default when you clone locally
476
- if r [0 ] == "origin" :
477
- break
478
-
483
+ # Get default remote
484
+ remote = Git .getremote ()
479
485
if not remote :
480
486
return - 1
481
487
@@ -499,6 +505,17 @@ def outgoing():
499
505
def isdetached ():
500
506
return Git .getbranch () == "HEAD"
501
507
508
+ # Finds default remote
509
+ def getremote (rtype = 'fetch' ):
510
+ remote = None
511
+ remotes = Git .getremotes ('push' )
512
+ for r in remotes :
513
+ remote = r [0 ]
514
+ # Prefer origin which is Git's default remote when cloning
515
+ if r [0 ] == "origin" :
516
+ break
517
+ return remote
518
+
502
519
# Finds all associated remotes for the specified remote type
503
520
def getremotes (rtype = 'fetch' ):
504
521
result = []
0 commit comments